Class: Uncaught::Middleware
- Inherits:
-
Object
- Object
- Uncaught::Middleware
- Defined in:
- lib/uncaught/integrations/rails.rb
Overview
Rack middleware for Rails / Rack applications.
-
Adds an HTTP breadcrumb for every request.
-
Captures unhandled exceptions and re-raises them.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
25 26 27 28 |
# File 'lib/uncaught/integrations/rails.rb', line 25 def initialize(app) @app = app @client = Uncaught.client end |
Instance Method Details
#call(env) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/uncaught/integrations/rails.rb', line 30 def call(env) # Refresh client reference in case it was reconfigured. @client = Uncaught.client if @client.nil? if @client @client.( type: "api_call", category: "http", message: "#{env['REQUEST_METHOD']} #{env['PATH_INFO']}" ) end @app.call(env) rescue => e if @client request_info = RequestInfo.new( method: env["REQUEST_METHOD"], url: env["REQUEST_URI"] || env["PATH_INFO"] ) @client.capture_error(e, request: request_info) end raise end |