class Beekeeper::ExceptionBlueprinter

Public Class Methods

get_error(exception, options) click to toggle source
# File lib/beekeeper/exception_blueprinter.rb, line 25
def self.get_error exception, options
  status = get_status exception, options
  Rack::Utils::HTTP_STATUS_CODES.fetch(status, Rack::Utils::HTTP_STATUS_CODES[500])
end
get_errors(exception) click to toggle source
# File lib/beekeeper/exception_blueprinter.rb, line 37
def self.get_errors exception
  return [
    {
      code: exception.class.name,
      message: exception.message
    }
  ]
end
get_status(exception, options) click to toggle source
# File lib/beekeeper/exception_blueprinter.rb, line 21
def self.get_status exception, options
  exception.try(:status) || get_status_from_backtrace(exception, options)
end
get_status_from_backtrace(exception, options) click to toggle source
# File lib/beekeeper/exception_blueprinter.rb, line 30
def self.get_status_from_backtrace exception, options
  request = options[:request]
  backtrace_cleaner = request.env['action_dispatch.backtrace_cleaner']
  wrapper = ::ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception)
  return wrapper.status_code
end