Exception notifier not working


#1

I installed the exception notifier via:
/script/plugin install -x exception_notification

It resides in the vendor/exception_notification directory (as
advertised). I’ve configured environment.rb with the following:

ExceptionNotifier.exception_recipients = %w(removed_email_address@domain.invalid)
ExceptionNotifier.sender_address = %(“Application Error”
removed_email_address@domain.invalid)

Note: the documentation didn’t say where in environment.rb to put it,
so I put it outside of any functions.

Rails is configured (through environment.rb) as:
RAILS_GEM_VERSION = ‘1.1.2’

In my application controller, I have:
include ExceptionNotifiable
…as the documentation says

The problem: I get nothing. No emails, no pretty error page, just the
standard error template that I always get when there is an error.

I’ve restarted the server countless times to no avail, and to
short-circuit the fact that I’m running the server and making page
requests locally, I commented out the code in ExceptionNotifiable as
such:
def local_request?

remote = IPAddr.new(request.remote_ip)

!self.class.local_addresses.detect { |addr| addr.include?(remote)

}.nil?
false
end

…and I’ve also tried:
def local_addresses
‘addresses = read_inheritable_attribute(:local_addresses)
unless addresses
addresses = [IPAddr.new(“127.0.0.1”)]
write_inheritable_attribute(:local_addresses, addresses)
end
addresses’
nil
end

The README says to override the does-not-work-locally by putting
“local_addresses.clear” somewhere in your controller. I tried putting
it in a before_filter function and I get errors that “local_addresses”
could not be found. I attempted to prefix it with
ExceptionNotifier::ClassMethods::local_addresses.clear to no avail. So
I resorted to commenting out the functions in ExceptionNotifier as
described previously, and still nothing.

Any ideas why it’s not working?


#2

You’ll have to tell ActionMailer how to send the email still.
http://wiki.rubyonrails.com/rails/pages/HowToSendEmailsWithActionMailer

That should clear everything up. Well, once you get ActionMailer up and
working.

RSL


#3

I already have ActionMailer configured to send emails, and it’s sending
mail for other parts of the application. I’m not sure if there is some
specific configuration for the exception notifier or not?

Russell N. wrote:

You’ll have to tell ActionMailer how to send the email still.
http://wiki.rubyonrails.com/rails/pages/HowToSendEmailsWithActionMailer

That should clear everything up. Well, once you get ActionMailer up and
working.

RSL


#4

Yes, as follows, notice I have the email outside of any function (I
think this is ok?) Note: I’ve substituted dummy email addresses:

Rails::Initializer.run do |config|
end

ExceptionNotifier.exception_recipients = %w(removed_email_address@domain.invalid)
ExceptionNotifier.sender_address = %w(“Application Error”
removed_email_address@domain.invalid)

Russell N. wrote:

Does your config/environment.rb contain a section similar to the
following?
RSL


#5

I think the problem is that space between “Application Error” and the
email
address. the %w method sees two entries there, the first of which is not
a
valid email address and might be causing further failures. You might try

ExceptionNotifier.sender_address = [“Application Error <
removed_email_address@domain.invalid>”]

or just leaving out that “Application Error” part. The email’s subject
makes
it clear that it’s an error. Lemme know if that works.

RSL


#6

Russell N. wrote:

I think the problem is that space between “Application Error” and the
email
address. the %w method sees two entries there, the first of which is not
a
valid email address and might be causing further failures. You might try

ExceptionNotifier.sender_address = [“Application Error <
removed_email_address@domain.invalid>”]

or just leaving out that “Application Error” part. The email’s subject
makes
it clear that it’s an error. Lemme know if that works.

RSL

Well, I fixed it. The notifier doesn’t work in development mode. When
I changed to production mode it worked. Thanks for the help.


#7

Does your config/environment.rb contain a section similar to the
following?

Error reports for your site will be sent to all email addresses in the

%w{} array.
ExceptionNotifier.exception_recipients = %w( removed_email_address@domain.invalid)

Sender address should be different from all recipient since some mail

servers

have problems when both are the same. Spam-guard related I’m sure.

ExceptionNotifier.sender_address = %w( removed_email_address@domain.invalid)

Note that the sender and recipients should be different addresses. This
may
[or may not] be part of the problem too. Hope this helps.

RSL