Class: Rack::Hoptoad
- Inherits:
-
Object
- Object
- Rack::Hoptoad
- Defined in:
- lib/rack/hoptoad.rb
Overview
Catches all exceptions raised from the app it wraps and posts the results to hoptoad.
Constant Summary collapse
- VERSION =
'0.1.2'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#environment_filters ⇒ Object
Returns the value of attribute environment_filters.
-
#rack_environment ⇒ Object
Returns the value of attribute rack_environment.
-
#report_under ⇒ Object
Returns the value of attribute report_under.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #environment_filter_keys ⇒ Object
-
#initialize(app, api_key = nil, rack_environment = 'RACK_ENV') {|_self| ... } ⇒ Hoptoad
constructor
A new instance of Hoptoad.
Constructor Details
#initialize(app, api_key = nil, rack_environment = 'RACK_ENV') {|_self| ... } ⇒ Hoptoad
Returns a new instance of Hoptoad.
13 14 15 16 17 18 19 20 |
# File 'lib/rack/hoptoad.rb', line 13 def initialize(app, api_key = nil, rack_environment = 'RACK_ENV') @app = app @api_key = api_key @report_under = %w(staging production) @rack_environment = rack_environment @environment_filters = %w(AWS_ACCESS_KEY AWS_SECRET_ACCESS_KEY AWS_ACCOUNT SSH_AUTH_SOCK) yield self if block_given? end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
11 12 13 |
# File 'lib/rack/hoptoad.rb', line 11 def api_key @api_key end |
#environment_filters ⇒ Object
Returns the value of attribute environment_filters.
11 12 13 |
# File 'lib/rack/hoptoad.rb', line 11 def environment_filters @environment_filters end |
#rack_environment ⇒ Object
Returns the value of attribute rack_environment.
11 12 13 |
# File 'lib/rack/hoptoad.rb', line 11 def rack_environment @rack_environment end |
#report_under ⇒ Object
Returns the value of attribute report_under.
11 12 13 |
# File 'lib/rack/hoptoad.rb', line 11 def report_under @report_under end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rack/hoptoad.rb', line 22 def call(env) status, headers, body = begin @app.call(env) rescue StandardError, LoadError, SyntaxError => boom # TODO don't allow exceptions from send_notification to # propogate notified = send_notification boom, env env['hoptoad.notified'] = notified raise end send_notification env['rack.exception'], env if env['rack.exception'] [status, headers, body] end |
#environment_filter_keys ⇒ Object
37 38 39 |
# File 'lib/rack/hoptoad.rb', line 37 def environment_filter_keys @environment_filters.flatten end |