Class: Binnacle::Trap::Middleware
- Inherits:
-
Object
- Object
- Binnacle::Trap::Middleware
- Defined in:
- lib/binnacle/trap/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
- #report?(exception, headers) ⇒ Boolean
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
5 6 7 |
# File 'lib/binnacle/trap/middleware.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/binnacle/trap/middleware.rb', line 9 def call(env) _, headers, _ = response = @app.call(env) response rescue Exception => exception if report?(exception, headers) begin Binnacle.binnacle_logger.debug "Binnacle: reporting exception: #{exception.class.name}" Binnacle.report_exception(exception, env) rescue # prevent the observer effect ensure raise end else raise end end |
#report?(exception, headers) ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/binnacle/trap/middleware.rb', line 27 def report?(exception, headers) exception_class_name = exception.class.name if Binnacle.configuration.trap? if Binnacle.configuration.ignore_cascade_pass? if headers && headers['X-Cascade'] report = headers['X-Cascade'] != 'pass' else report = true end end Binnacle.configuration.ignored_exceptions.include?(exception_class_name) ? false : report else false end end |