18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rake_notifier.rb', line 18
def handle_exception(exception)
if Rake.email_from.blank? if defined? ExceptionNotifier
args = Rails::Application.subclasses.map {|app| app.config.middleware.middlewares }.flatten.select {|m| m === ExceptionNotifier }.map {|en| en.args }.flatten
if args.blank?
raise "Please setup your ExceptionNotifier first"
else
Rake.email_from = args[0][:sender_address]
Rake.email_to = args.map {|i| i[:exception_recipients] }.flatten.join(", ")
end
end
end
$stderr.puts
$stderr.puts subject = "Rake exception - #{exception.message}"
$stderr.puts body = "#{exception.message}\n\n#{exception.backtrace.join("\n")}"
Pony.mail(:from => Rake.email_from, :to => Rake.email_to, :subject => subject, :body => body)
$stderr.puts
$stderr.puts "Exception details sent to #{Rake.email_to}"
$stderr.puts
end
|