Class: Exceptify::Rack
- Inherits:
-
Object
- Object
- Exceptify::Rack
- Defined in:
- lib/exceptify/rack.rb
Defined Under Namespace
Classes: CascadePassException
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app, options = {}) ⇒ Rack
Returns a new instance of Rack.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/exceptify/rack.rb', line 11 def initialize(app, = {}) @app = app @dispatcher = .delete(:dispatcher) @configuration = .delete(:configuration) @ignore_cascade_pass = .delete(:ignore_cascade_pass) { true } return if @dispatcher return if .empty? && @configuration.nil? @configuration ||= Exceptify.configuration.copy (@configuration, ) @dispatcher = Dispatcher.new(@configuration) end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
9 10 11 |
# File 'lib/exceptify/rack.rb', line 9 def configuration @configuration end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/exceptify/rack.rb', line 25 def call(env) _, headers, = response = @app.call(env) if !@ignore_cascade_pass && headers["X-Cascade"] == "pass" msg = "This exception means that the preceding Rack middleware set the 'X-Cascade' header to 'pass' -- in " \ "Rails, this often means that the route was not found (404 error)." raise CascadePassException, msg end response rescue Exception => e # standard:disable Lint/RescueException env["exceptify.delivered"] = true if dispatcher.notify_exception(e, env: env) raise e unless e.is_a?(CascadePassException) response end |