class Blacksheep::Decorators::DefaultErrorHandler
Public Instance Methods
handle(exception)
click to toggle source
# File lib/blacksheep/decorators/default_error_handler.rb, line 7 def handle(exception) json = status = nil case exception when Blacksheep::ActionError json = { errors: [ pointer: { source: exception.backtrace.first, identifier: exception.identifier, }, title: exception.title, detail: exception.message, ] } status = exception.status # when Pundit::NotAuthorizedError # json = { # errors: [ # pointer: { # source: not_authorized_pointer(exception) # }, # title: "#{exception.class}", # detail: "#{exception.message}", # ] # } # status = :unauthorized # 401 # when Exceptions::AuthenticationInvalid # json = { # errors: [ # pointer: { # source: 'Secured Module' # }, # title: "#{exception.class}", # detail: "#{exception.message}", # ] # } # status = :unauthorized # 401 else json = { errors: [ pointer: { source: 'Internal' }, title: "#{exception.class}", detail: "#{exception.message}", ] } end status ||= :internal_server_error ActionResult.new(json, status) end