Class: Grape::DSL::RescueOptions

Inherits:
Data
  • Object
show all
Defined in:
lib/grape/dsl/rescue_options.rb

Overview

Immutable value object holding the response-shaping booleans accepted by Grape::DSL::RequestResponse#rescue_from. Stored on the inheritable settings as namespace_stackable[:rescue_options] and delegated to by Grape::Middleware::Error (which forwards backtrace/original_exception to the formatter as include_backtrace/include_original_exception).

Defaults are duplicated on #initialize here and on #rescue_from‘s signature on purpose: keeping them on both sides means each entry point is self-documenting without needing to import a shared constant — the DSL signature shows what a user sees in the IDE, and the Data object has working defaults when constructed directly (middleware `DEFAULT_OPTIONS`, spec fixtures, etc.). The two must stay in lockstep.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backtrace: false, original_exception: false) ⇒ RescueOptions

Returns a new instance of RescueOptions.



19
20
21
# File 'lib/grape/dsl/rescue_options.rb', line 19

def initialize(backtrace: false, original_exception: false)
  super
end

Instance Attribute Details

#backtraceObject (readonly)

Returns the value of attribute backtrace

Returns:

  • (Object)

    the current value of backtrace



18
19
20
# File 'lib/grape/dsl/rescue_options.rb', line 18

def backtrace
  @backtrace
end

#original_exceptionObject (readonly)

Returns the value of attribute original_exception

Returns:

  • (Object)

    the current value of original_exception



18
19
20
# File 'lib/grape/dsl/rescue_options.rb', line 18

def original_exception
  @original_exception
end