Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created May 18, 2012 15:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luislavena/2725772 to your computer and use it in GitHub Desktop.
Save luislavena/2725772 to your computer and use it in GitHub Desktop.
How to send exception information from Rake tasks to Exceptional.io
# 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
# before tasks/rails
require "rake/exceptional"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment