Class: Beekeeper::ExceptionBlueprinter
- Inherits:
-
Blueprinter::Base
- Object
- Blueprinter::Base
- Beekeeper::ExceptionBlueprinter
- Defined in:
- lib/beekeeper/exception_blueprinter.rb
Class Method Summary collapse
- .get_error(exception, options) ⇒ Object
- .get_errors(exception) ⇒ Object
- .get_status(exception, options) ⇒ Object
- .get_status_from_backtrace(exception, options) ⇒ Object
Class Method Details
.get_error(exception, options) ⇒ Object
25 26 27 28 |
# File 'lib/beekeeper/exception_blueprinter.rb', line 25 def self.get_error exception, status = get_status exception, Rack::Utils::HTTP_STATUS_CODES.fetch(status, Rack::Utils::HTTP_STATUS_CODES[500]) end |
.get_errors(exception) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/beekeeper/exception_blueprinter.rb', line 37 def self.get_errors exception return [ { code: exception.class.name, message: exception. } ] end |
.get_status(exception, options) ⇒ Object
21 22 23 |
# File 'lib/beekeeper/exception_blueprinter.rb', line 21 def self.get_status exception, exception.try(:status) || get_status_from_backtrace(exception, ) end |
.get_status_from_backtrace(exception, options) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/beekeeper/exception_blueprinter.rb', line 30 def self.get_status_from_backtrace exception, request = [:request] backtrace_cleaner = request.env['action_dispatch.backtrace_cleaner'] wrapper = ::ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception) return wrapper.status_code end |