Class: RescueRegistry::ShowExceptions

Inherits:
Object
  • Object
show all
Defined in:
lib/rescue_registry/show_exceptions.rb

Defined Under Namespace

Classes: MimeType

Constant Summary collapse

CONTENT_TYPES =

Unfortunately, Rail’s nice mime types are in ActionDispatch which we’d rather not require

{
  jsonapi: "application/vnd.api+json",
  json:    "application/json",
  xml:     ["application/xml", "text/xml"],
  plain:   "text/plain"
}

Instance Method Summary collapse

Constructor Details

#initialize(app, debug: false, content_types: CONTENT_TYPES) ⇒ ShowExceptions

Returns a new instance of ShowExceptions.



18
19
20
21
22
# File 'lib/rescue_registry/show_exceptions.rb', line 18

def initialize(app, debug: false, content_types: CONTENT_TYPES)
  @app = app
  @content_types = content_types
  @debug = debug
end

Instance Method Details

#call(env) ⇒ Object



24
25
26
27
28
# File 'lib/rescue_registry/show_exceptions.rb', line 24

def call(env)
  @app.call(env)
rescue Exception => exception
  handle_exception(env, exception)
end