Class: Noise::ExceptionsApp

Inherits:
Object
  • Object
show all
Defined in:
lib/noise/exceptions_app.rb

Overview

Custom rails exception app to render all API level errors as JSON.

Why it needed: in case we use default ActionController’s ‘rescue_from` we will not be able to properly handle and render exceptions raised in middlewares (like Warden), so for processing of all possible exceptions we configure Rails’ ‘config.exceptions_app` to use our own API-specific implementation.

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object

Parameters:

  • env (Hash)

    rack env



14
15
16
17
# File 'lib/noise/exceptions_app.rb', line 14

def call(env)
  responder = build_responder(env)
  [responder.status_code, responder.headers, [responder.body]]
end