Class: SnitchReporting::Rack
- Inherits:
-
Object
- Object
- SnitchReporting::Rack
- Defined in:
- lib/snitch_reporting/rack.rb
Defined Under Namespace
Classes: SnitchException
Instance Attribute Summary collapse
-
#notify_callback ⇒ Object
Returns the value of attribute notify_callback.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, notify_callback = nil) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app, notify_callback = nil) ⇒ Rack
Returns a new instance of Rack.
5 6 7 8 |
# File 'lib/snitch_reporting/rack.rb', line 5 def initialize(app, notify_callback=nil) @app = app @notify_callback = notify_callback end |
Instance Attribute Details
#notify_callback ⇒ Object
Returns the value of attribute notify_callback.
3 4 5 |
# File 'lib/snitch_reporting/rack.rb', line 3 def notify_callback @notify_callback end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/snitch_reporting/rack.rb', line 10 def call(env) response = @app.call(env) _, headers, = response if 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 SnitchException, msg end response rescue Exception => exception occurrence = ::SnitchReporting::SnitchReport.fatal(exception, env: env) notify_callback.call(occurrence) if occurrence.notify? raise exception unless exception.is_a?(SnitchException) response end |