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.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/exception_notifier.rb', line 13 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] @options[:ignore_exceptions] ||= self.class.default_ignore_exceptions end |
Class Method Details
.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 if defined? ::ActiveRecord::RecordNotFound exceptions << ::AbstractController::ActionNotFound if defined? ::AbstractController::ActionNotFound exceptions << ::ActionController::RoutingError if defined? ::ActionController::RoutingError end end |
Instance Method Details
#call(env) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/exception_notifier.rb', line 24 def call(env) @app.call(env) rescue Exception => exception = (env['exception_notifier.options'] ||= Notifier.) .reverse_merge!(@options) unless Array.wrap([:ignore_exceptions]).include?(exception.class) Notifier.exception_notification(env, exception).deliver env['exception_notifier.delivered'] = true end raise exception end |