Class: ExceptionNotification::Rack
- Inherits:
-
Object
- Object
- ExceptionNotification::Rack
- Defined in:
- lib/exception_notification/rack.rb
Defined Under Namespace
Classes: CascadePassException
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app, options = {}) ⇒ Rack
Returns a new instance of Rack.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/exception_notification/rack.rb', line 5 def initialize(app, = {}) @app = app ExceptionNotifier.ignored_exceptions = .delete(:ignore_exceptions) if .key?(:ignore_exceptions) if .key?(:ignore_if) rack_ignore = .delete(:ignore_if) ExceptionNotifier.ignore_if do |exception, | .key?(:env) && rack_ignore.call([:env], exception) end end if .key?(:ignore_crawlers) ignore_crawlers = .delete(:ignore_crawlers) ExceptionNotifier.ignore_if do |exception, | .key?(:env) && from_crawler([:env], ignore_crawlers) end end @ignore_cascade_pass = .delete(:ignore_cascade_pass) { true } .each do |notifier_name, | ExceptionNotifier.register_exception_notifier(notifier_name, ) end end |
Instance Method Details
#call(env) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/exception_notification/rack.rb', line 31 def call(env) _, headers, _ = response = @app.call(env) if !@ignore_cascade_pass && headers['X-Cascade'] == 'pass' msg = "This exception means that the preceding Rack middleware set the 'X-Cascade' header to 'pass' -- in " << "Rails, this often means that the route was not found (404 error)." raise CascadePassException, msg end response rescue Exception => exception if ExceptionNotifier.notify_exception(exception, :env => env) env['exception_notifier.delivered'] = true end raise exception unless exception.is_a?(CascadePassException) response end |