Skip to content

Commit

Permalink
refactor: minor code modification
Browse files Browse the repository at this point in the history
  • Loading branch information
naqvis committed Nov 29, 2024
1 parent d1d5b9d commit e35ecda
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/controllers/application.cr
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ abstract class Application < ActionController::Base
# 404 if resource not present
@[AC::Route::Exception(Error::NotFound, status_code: HTTP::Status::NOT_FOUND)]
@[AC::Route::Exception(PgORM::Error::RecordNotFound, status_code: HTTP::Status::NOT_FOUND)]
@[AC::Route::Exception(Error::TenantNotFound, status_code: HTTP::Status::NOT_FOUND)]
def sql_record_not_found(error) : CommonError
Log.debug { error.message }
render_error(error)
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/calendars.cr
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Calendars < Application
all_calendars.concat(candidate_calendars)
calendars = all_calendars.to_a

render :not_found, json: "no tenants exist" if calendars.empty?
raise Error::TenantNotFound.new("no tenants exist") if calendars.empty?

# perform availability request
period_start = Time.unix(period_start)
Expand Down
3 changes: 3 additions & 0 deletions src/error.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class Error < Exception
class NotFound < Error
end

class TenantNotFound < Error
end

class BadUpstreamResponse < Error
end

Expand Down

0 comments on commit e35ecda

Please sign in to comment.