Created
December 5, 2011 15:16
-
-
Save skippy/1433920 to your computer and use it in GitHub Desktop.
safely call hoptoad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyApp | |
class Notifier | |
class << self | |
def notify(*args) | |
safely_trigger(Airbrake, :notify, args) | |
end | |
def safely_trigger(klass, method, args) | |
#simple, safe; heavy but it isn't called very often! | |
Thread.new do | |
begin | |
klass.send(method, *args) | |
rescue Exception => e | |
# don't die because of stupid exceptions | |
Rails.logger.error "SweetSpot::Notifier failure: #{e.message}\n#{e.backtrace.join("\n ")}" | |
nil | |
end | |
end | |
end | |
private :safely_trigger | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment