Class: Grape::Middleware::Error
- Defined in:
- lib/grape/middleware/error.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call!(env) ⇒ Object
- #default_options ⇒ 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, #mime_types, #response
Methods included from DSL::Headers
Methods included from Helpers
Constructor Details
#initialize(app, *options) ⇒ Error
Returns a new instance of Error.
27 28 29 30 |
# File 'lib/grape/middleware/error.rb', line 27 def initialize(app, *) super self.class.include(@options[:helpers]) if @options[:helpers] end |
Instance Method Details
#call!(env) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/grape/middleware/error.rb', line 32 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 |
#default_options ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/grape/middleware/error.rb', line 6 def { default_status: 500, # default status returned on error default_message: '', format: :txt, helpers: nil, formatters: {}, error_formatters: {}, rescue_all: false, # true to rescue all exceptions rescue_grape_exceptions: false, rescue_subclasses: true, # rescue subclasses of exceptions listed rescue_options: { backtrace: false, # true to display backtrace, true to let Grape handle Grape::Exceptions original_exception: false # true to display exception }, rescue_handlers: {}, # rescue handler blocks base_only_rescue_handlers: {}, # rescue handler blocks rescuing only the base class all_rescue_handler: nil # rescue handler block to rescue from all exceptions } end |