Class: ExceptionNotifier
- Inherits:
-
Object
- Object
- ExceptionNotifier
- Defined in:
- lib/exception_notifier.rb,
lib/exception_notifier/notifier.rb
Defined Under Namespace
Classes: Notifier
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ ExceptionNotifier
constructor
A new instance of ExceptionNotifier.
Constructor Details
#initialize(app, options = {}) ⇒ ExceptionNotifier
Returns a new instance of ExceptionNotifier.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/exception_notifier.rb', line 17 def initialize(app, = {}) @app, @options = app, Notifier.default_sender_address = @options[:sender_address] Notifier.default_exception_recipients = @options[:exception_recipients] Notifier.default_email_prefix = @options[:email_prefix] Notifier.default_sections = @options[:sections] Notifier.default_background_sections = @options[:background_sections] Notifier.default_verbose_subject = @options[:verbose_subject] Notifier.default_normalize_subject = @options[:normalize_subject] @options[:ignore_exceptions] ||= self.class.default_ignore_exceptions @options[:ignore_crawlers] ||= self.class.default_ignore_crawlers @options[:ignore_if] ||= lambda { |env, e| false } end |
Class Method Details
.default_ignore_crawlers ⇒ Object
13 14 15 |
# File 'lib/exception_notifier.rb', line 13 def self.default_ignore_crawlers [] end |
.default_ignore_exceptions ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/exception_notifier.rb', line 5 def self.default_ignore_exceptions [].tap do |exceptions| exceptions << 'ActiveRecord::RecordNotFound' exceptions << 'AbstractController::ActionNotFound' exceptions << 'ActionController::RoutingError' end end |
Instance Method Details
#call(env) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/exception_notifier.rb', line 33 def call(env) @app.call(env) rescue Exception => exception = (env['exception_notifier.options'] ||= Notifier.) .reverse_merge!(@options) unless ignored_exception([:ignore_exceptions], exception) || from_crawler([:ignore_crawlers], env['HTTP_USER_AGENT']) || conditionally_ignored([:ignore_if], env, exception) Notifier.exception_notification(env, exception).deliver env['exception_notifier.delivered'] = true end raise exception end |