Class: Rack::Radar
- Inherits:
-
Object
- Object
- Rack::Radar
- Defined in:
- lib/radar/integration/rack.rb
Overview
A rack middleware which allows Radar to catch any exceptions thrown down a Rack app and report it to the given Radar application.
use Rack::Radar, :application => radar_app
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = nil) ⇒ Radar
constructor
A new instance of Radar.
Constructor Details
#initialize(app, opts = nil) ⇒ Radar
Returns a new instance of Radar.
25 26 27 28 29 30 31 32 |
# File 'lib/radar/integration/rack.rb', line 25 def initialize(app, opts=nil) @app = app @opts = { :application => nil }.merge(opts || {}) raise ArgumentError.new("Must provide a radar application in `:application`") if !@opts[:application] || !@opts[:application].is_a?(::Radar::Application) # Enable the rack data extension @opts[:application].config.data_extensions.use :rack end |
Instance Method Details
#call(env) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/radar/integration/rack.rb', line 34 def call(env) @app.call(env) rescue Exception => e @opts[:application].report(e, :rack_request => Rack::Request.new(env), :rack_env => env) raise end |