Class: Grape::Middleware::Error

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Includes:
PrecomputedContentTypes
Defined in:
lib/grape/middleware/error.rb

Defined Under Namespace

Classes: Options

Constant Summary collapse

FAILSAFE_STATUS =

Emitted by #render_failsafe_response once even the framework's own message could not be rendered. Deliberately built without a formatter, an i18n lookup or anything else that could be the thing that is broken.

500
FAILSAFE_MESSAGE =
'500 Internal Server Error'
FAILSAFE_CONTENT_TYPE =
'text/plain'

Instance Attribute Summary

Attributes inherited from Base

#app, #config, #env, #options

Instance Method Summary collapse

Methods included from PrecomputedContentTypes

#content_type, #content_type_for, #content_types, #initialize, #mime_types

Methods inherited from Base

#after, #before, #call, #context, #initialize, #query_params, #rack_request, #response

Methods included from DSL::Headers

#header

Instance Method Details

#call!(env) ⇒ Object



60
61
62
63
64
65
# File 'lib/grape/middleware/error.rb', line 60

def call!(env)
  @env = env
  error_response(catch(:error) { return @app.call(@env) })
rescue Exception => e # rubocop:disable Lint/RescueException
  run_rescue_handler(find_handler(e.class), e, @env[Grape::Env::API_ENDPOINT])
end