Class: Grape::Middleware::Error
- Defined in:
- lib/grape/middleware/error.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ default_status: 500, default_message: '', format: :txt, rescue_all: false, rescue_grape_exceptions: false, rescue_subclasses: true, rescue_options: { backtrace: false, original_exception: false }.freeze }.freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call!(env) ⇒ Object
-
#initialize(app, **options) ⇒ Error
constructor
A new instance of Error.
Methods inherited from Base
#after, #before, #call, #content_type, #content_type_for, #content_types, #context, #mime_types, #query_params, #rack_request, #response
Methods included from DSL::Headers
Constructor Details
#initialize(app, **options) ⇒ Error
19 20 21 22 |
# File 'lib/grape/middleware/error.rb', line 19 def initialize(app, **) super self.class.include([:helpers]) if [:helpers] end |
Instance Method Details
#call!(env) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/grape/middleware/error.rb', line 24 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 |