class Noise::ExceptionsApp
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.
Public Instance Methods
call(env)
click to toggle source
@param env [Hash] rack env
# File lib/noise/exceptions_app.rb, line 14 def call(env) responder = build_responder(env) [responder.status_code, responder.headers, [responder.body]] end
Private Instance Methods
build_responder(env)
click to toggle source
# File lib/noise/exceptions_app.rb, line 21 def build_responder(env) error = env['action_dispatch.exception'] responder_class = error.respond_to?(:responder_class) ? error.responder_class : ExceptionResponder responder_class.new(env) end