Class: Rocketgraph::ErrorReportingMiddleware
- Inherits:
-
Object
- Object
- Rocketgraph::ErrorReportingMiddleware
- Defined in:
- lib/rocketgraph.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, endpoint, api_key) ⇒ ErrorReportingMiddleware
constructor
A new instance of ErrorReportingMiddleware.
Constructor Details
#initialize(app, endpoint, api_key) ⇒ ErrorReportingMiddleware
7 8 9 10 11 12 13 |
# File 'lib/rocketgraph.rb', line 7 def initialize(app, endpoint, api_key) @app = app @endpoint = endpoint @api_key = api_key @custom_logger = nil setup_logger_interception end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rocketgraph.rb', line 15 def call(env) begin status, headers, body = @app.call(env) if status >= 400 report_error( error: StandardError.new("HTTP #{status}"), env: env, status_code: status ) end [status, headers, body] rescue StandardError => e report_error(error: e, env: env, status_code: 500) raise end end |