Module: HoptoadNotifier::Catcher

Included in:
Sender
Defined in:
lib/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb

Overview

Include this module in Controllers in which you want to be notified of errors.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



223
224
225
226
227
228
229
# File 'lib/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb', line 223

def self.included(base) #:nodoc:
  if base.instance_methods.map(&:to_s).include? 'rescue_action_in_public' and !base.instance_methods.map(&:to_s).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)
    base.hide_action(:notify_hoptoad, :inform_hoptoad) if base.respond_to?(:hide_action)
  end
end

Instance Method Details

#loggerObject

Returns the default logger or a logger that prints to STDOUT. Necessary for manual notifications outside of controllers.



250
251
252
253
254
# File 'lib/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb', line 250

def logger
  ActiveRecord::Base.logger
rescue
  @logger ||= Logger.new(STDERR)
end

#notify_hoptoad(hash_or_exception) ⇒ Object

This method should be used for sending manual notifications while you are still inside the controller. Otherwise it works like HoptoadNotifier.notify.



240
241
242
243
244
245
246
# File 'lib/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb', line 240

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.



233
234
235
236
# File 'lib/vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb', line 233

def rescue_action_in_public_with_hoptoad exception
  notify_hoptoad(exception) unless ignore?(exception) || ignore_user_agent?
  rescue_action_in_public_without_hoptoad(exception)
end