Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 43d0ccb8b374e25937814c8ccaa7332ea52cc812 @oscardelben oscardelben committed Mar 28, 2011
Showing with 55 additions and 0 deletions.
  1. BIN .Rakefile.swp
  2. BIN .Readme.swp
  3. BIN .test.rake.swp
  4. +43 −0 Rakefile
  5. +5 −0 Readme
  6. +7 −0 test.rake
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,43 @@
+require 'pony'
+
+EMAIL_FROM = 'server@example.com'
+EMAIL_TO = 'me@example.com'
+
+def handle_exception(exception)
+ $stderr.puts "#{name} aborted!"
+ $stderr.puts exception.message
+ $stderr.puts exception.backtrace.join("\n")
+
+ # Send email
+
+ subject = "Rake exception - #{exception.message}"
+ body = "#{exception.message}\n\n#{exception.backtrace.join("\n")}"
+
+ Pony.mail(:to => EMAIL_TO, :from => EMAIL_FROM, :subject => subject, :body => body)
+
+ $stderr.puts
+ $stderr.puts
+ $stderr.puts "Exception details sent to #{EMAIL_TO}"
+end
+
+module Rake
+
+ class Application
+
+
+ def standard_exception_handling
+ begin
+ yield
+ rescue Exception => e
+ handle_exception(e)
+ exit(false)
+ end
+
+ end
+
+ end
+
+end
+
+# Include this to run 'rake test:foo'
+# load 'test.rake'
5 Readme
@@ -0,0 +1,5 @@
+Rake Notifier send a notification to your email address whenever a Rake task in your application fails.
+
+To use, install the pony gem, post the content of Rakefile into your own Rakefile, change FROM_EMAIL and TO_EMAIL and then you're ready to go.
+
+Project Status: alpha.
@@ -0,0 +1,7 @@
+namespace :test do
+
+ task :foo do
+ raise "Sample exception"
+ end
+
+end

0 comments on commit 43d0ccb

Please sign in to comment.