Class: RailsInformant::Middleware::ErrorCapture

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_informant/middleware/error_capture.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ErrorCapture

Returns a new instance of ErrorCapture.



4
5
6
# File 'lib/rails_informant/middleware/error_capture.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rails_informant/middleware/error_capture.rb', line 8

def call(env)
  @app.call(env).tap do |status, _headers, _body|
    # Only record rescued exceptions that resulted in a server error.
    # 4xx responses are expected application errors handled by ShowExceptions.
    if (exception = env["rails_informant.rescued_exception"]) && status.to_i >= 500
      record_exception exception, env:
    end
  end
rescue StandardError => exception
  record_exception(exception, env: env)
  raise
end