Module: HoptoadNotifier::Catcher
- Included in:
- Sender
- Defined in:
- lib/hoptoad_notifier.rb
Overview
Include this module in Controllers in which you want to be notified of errors.
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#logger ⇒ Object
Returns the default logger or a logger that prints to STDOUT.
-
#notify_hoptoad(hash_or_exception) ⇒ Object
(also: #inform_hoptoad)
This method should be used for sending manual notifications while you are still inside the controller.
-
#rescue_action_in_public_with_hoptoad(exception) ⇒ Object
Overrides the rescue_action method in ActionController::Base, but does not inhibit any custom processing that is defined with Rails 2’s exception helpers.
Class Method Details
.included(base) ⇒ Object
:nodoc:
139 140 141 142 143 144 |
# File 'lib/hoptoad_notifier.rb', line 139 def self.included(base) #:nodoc: if base.instance_methods.include? 'rescue_action_in_public' and !base.instance_methods.include? 'rescue_action_in_public_without_hoptoad' base.send(:alias_method, :rescue_action_in_public_without_hoptoad, :rescue_action_in_public) base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_hoptoad) end end |
Instance Method Details
#logger ⇒ Object
Returns the default logger or a logger that prints to STDOUT. Necessary for manual notifications outside of controllers.
167 168 169 170 171 |
# File 'lib/hoptoad_notifier.rb', line 167 def logger ActiveRecord::Base.logger rescue @logger ||= Logger.new(STDERR) end |
#notify_hoptoad(hash_or_exception) ⇒ Object Also known as: inform_hoptoad
This method should be used for sending manual notifications while you are still inside the controller. Otherwise it works like HoptoadNotifier.notify.
155 156 157 158 159 160 161 |
# File 'lib/hoptoad_notifier.rb', line 155 def notify_hoptoad hash_or_exception if public_environment? notice = normalize_notice(hash_or_exception) notice = clean_notice(notice) send_to_hoptoad(:notice => notice) end end |
#rescue_action_in_public_with_hoptoad(exception) ⇒ Object
Overrides the rescue_action method in ActionController::Base, but does not inhibit any custom processing that is defined with Rails 2’s exception helpers.
148 149 150 151 |
# File 'lib/hoptoad_notifier.rb', line 148 def rescue_action_in_public_with_hoptoad exception notify_hoptoad(exception) unless ignore?(exception) rescue_action_in_public_without_hoptoad(exception) end |