Class: DeadBro::ErrorMiddleware
- Inherits:
-
Object
- Object
- DeadBro::ErrorMiddleware
- Defined in:
- lib/dead_bro/error_middleware.rb
Constant Summary collapse
- EVENT_NAME =
"exception.uncaught"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, client = nil) ⇒ ErrorMiddleware
constructor
A new instance of ErrorMiddleware.
Constructor Details
#initialize(app, client = nil) ⇒ ErrorMiddleware
Returns a new instance of ErrorMiddleware.
9 10 11 12 |
# File 'lib/dead_bro/error_middleware.rb', line 9 def initialize(app, client = nil) @app = app @client = client || DeadBro.client end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dead_bro/error_middleware.rb', line 14 def call(env) @app.call(env) rescue Exception => exception # rubocop:disable Lint/RescueException begin payload = build_payload(exception, env) # Use the error class name as the event name event_name = exception.class.name.to_s event_name = EVENT_NAME if event_name.empty? @client.post_metric(event_name: event_name, payload: payload, force: true) rescue # Never let APM reporting interfere with the host app end raise end |