Skip to content

Commit 42fc0bf

Browse files
jcxplorerknzai
authored andcommitted
Uses the new ActionMailer API from Rails 3.0. Ensures Ruby 1.9.1 compatibility.
1 parent 1033b11 commit 42fc0bf

File tree

9 files changed

+19
-21
lines changed

9 files changed

+19
-21
lines changed

lib/exception_notifier.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def call(env)
2222
options.reverse_merge!(@options)
2323

2424
unless Array.wrap(options[:ignore_exceptions]).include?(exception.class)
25-
Notifier.deliver_exception_notification(env, exception)
25+
Notifier.exception_notification(env, exception).deliver
2626
end
2727

2828
raise exception

lib/exception_notifier/notifier.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,12 @@ def exception_notification(env, exception)
4545
instance_variable_set("@#{name}", value)
4646
end
4747

48-
content_type "text/plain"
49-
5048
prefix = "#{@options[:email_prefix]}#{@controller.controller_name}##{@controller.action_name}"
51-
subject "#{prefix} (#{@exception.class}) #{@exception.message.inspect}"
52-
53-
recipients @options[:exception_recipients]
54-
from @options[:sender_address]
55-
56-
render "#{mailer_name}/exception_notification"
49+
subject = "#{prefix} (#{@exception.class}) #{@exception.message.inspect}"
50+
51+
mail(:to => @options[:exception_recipients], :from => @options[:sender_address], :subject => subject) do |format|
52+
format.text { render "#{mailer_name}/exception_notification" }
53+
end
5754
end
5855

5956
private

lib/exception_notifier/views/exception_notifier/exception_notification.html.erb

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
A <%= @exception.class %> occurred in <%= @controller.controller_name %>#<%= @controller.action_name %>:
2+
3+
<%= raw @exception.message %>
4+
<%= raw @backtrace.first %>
5+
6+
<% sections = @sections.map do |section|
7+
summary = render(section).strip
8+
unless summary.blank?
9+
title = render("title", :title => section).strip
10+
"#{title}\n\n#{summary.gsub(/^/, " ")}\n\n"
11+
end
12+
end %>
13+
<%= raw sections.join %>

0 commit comments

Comments
 (0)