Created
May 18, 2012 15:08
-
-
Save luislavena/2725772 to your computer and use it in GitHub Desktop.
How to send exception information from Rake tasks to Exceptional.io
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
# lib/rake/exceptional.rb | |
module ExceptionalWithRake | |
def standard_exception_handling | |
begin | |
yield | |
rescue Exception => ex | |
# record the error in Exceptional.io | |
::Exceptional.handle(ex, "#{name} aborted!") | |
# show it in the output | |
$stderr.puts "#{name} aborted!" | |
$stderr.puts ex.message | |
# exit silently | |
exit(false) | |
end | |
end | |
end | |
if %w(production staging).include? ENV["RAILS_ENV"] | |
require "exceptional" | |
Exceptional::Config.load("config/exceptional.yml") | |
Rake.application.extend(ExceptionalWithRake) | |
end |
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
# before tasks/rails | |
require "rake/exceptional" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment