Skip to content

Instantly share code, notes, and snippets.

@lukemelia
Created October 2, 2009 19:57
Show Gist options
  • Save lukemelia/200060 to your computer and use it in GitHub Desktop.
Save lukemelia/200060 to your computer and use it in GitHub Desktop.
# def handle_exception_with_exception_notifier(exception)
# params_to_send = (respond_to? :filter_parameters) ? filter_parameters(params) : params
# ExceptionNotifier.notify(exception, {:request => request, :session => session}.merge(params_to_send))
# end
class ExceptionNotifier
include Singleton
def rescue_action_in_public(exception)
end
include HoptoadNotifier::Catcher
def self.rescue
if block_given?
begin
yield
rescue Exception => ex
self.notify(ex)
ActiveRecord::Base.logger.error "Caught exception: #{ex.inspect}"
end
end
end
def self.notify(ex, data = {})
if data.empty?
self.instance.notify_hoptoad(ex)
else
notice = {}
notice[:request] = data.delete(:request) if data.has_key?(:request)
notice[:session] = data.delete(:session) if data.has_key?(:session)
notice[:error_message] = "#{ex.class.name}: #{ex.message} #{ex.backtrace} #{data.inspect}"
notice[:error_class] = "#{ex.class.name} Error"
self.instance.notify_hoptoad(notice)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment