#104 Exception Notifications (revised)
Few things are worse than seeing a "Something went wrong" 500 error on your production application. Here I show how to be notified when this happens using exception_notification and mention several other alternatives.
- Download:
- source code
- mp4
- m4v
- webm
- ogv
When you set the action mailer delivery method in your production config file, where should that method live?
The
delivery_method
isn't a method that you define. It is normally set to:smtp
or:sendmail
depending on what you want to use to send email. See the guide for further details.Thanks Ryan!
Hey Ryan! Thanks again for all you do...love your screencast! I tried to set my production.rb file to deliver the email, but it is not working...
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "myserver",
:user_name => "fritz.rodriguez.jr",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true }
config.middleware.use ExceptionNotifier,
:sender_address => 'fritz.rodriguez.jr@gmail.com',
:exception_recpients => 'fritz.rodriguez.jr@gmail.com'
Any ideas? Thanks!
I'm not certain. Is the mail delivery method working? Try experimenting with it in the Rails console on your production server and see if it sends email.
This spelling error just got me too.
Robert Jackson below has the fix.
asciicasts doesn't seem to have a contact either :(
airbrake also has a (experimental) javascript exception notifier, that logs javascript exceptions too. the stack trace is often not too useful, but it's worth a look if your application relies heavily on javascript.
the free plan is good enough to test it out and setup is easy
what bugs me a little bit about it is, that I can't log ruby and javascript exceptions to different projects, maybe in the future if I have a little time I can make a fork of the gem that will do just that
Instead of letter_opener you can also use http://mocksmtpapp.com/ it's simply brilliant to test emails in development.
There used to be a gem that put this into the DB and had an interface , why has everyone move way from that? is there something wrong with that approach?
Receiving exceptions by email is great because you can set it up to be notified when this happens. Also if you're providing an in-app interface for browsing exceptions you need to worry about locking it down. Having a database of exceptions is handy, but Gmail search works pretty well.
Another great screencast! It is really helpful to see some of these older ones redone.
Looks like there is a small typo in the ASCIICast version where it says what to put in config/environments/development.rb: "exception_recpients" should be "exception_recipients".
Thanks again for all the hard work!
You mention in your video that Airbrake is a paid service, but there is actually a free version as well: https://airbrakeapp.com/account/new/Free
Great screencast! One question, I keep getting exception notifications for the default_ignore_exceptions, why is this? Has anyone experienced this problem?
Encoding::ConverterNotFoundError in Pages#index
Showing /usr/local/rvm/gems/ruby-1.9.2-p320@table/gems/exception_notification-3.0.0/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb where line #22 raised:
code converter not found (UTF-8 to UTF-16)
+1
+1
this => https://github.com/smartinez87/exception_notification/issues/113
ActionView::MissingTemplate: Missing partial exception_notifier/current_user
Any clues?
Following the instructions from this screencast, I was able to configure the gem to work on my local machine (a Mac) perfectly fine. However, deploying the application via capistrano to a Linux box, running the app with unicorn doesn't appear to be working. My unicorn.log contains the following error:
E, [2013-04-24T15:20:23.211288 #6163] ERROR -- : uninitialized constant ExceptionNotifier (NameError)
/path/to/app/releases/20130424201053/config/environments/production.rb:80:in `block in '
even though the gem is installed. I can't figure out how to load the library. Any help?
Do you solve this problem? I have the same one.
Solve by unicorn stop and then unicorn start instead of restart.
To work with the gem's latest update, you have to change the line:
config.middleware.use ExceptionNotification,
to
config.middleware.use ExceptionNotification::Rack,
Raygun is yet another option.
Does the
exception_notification
gem send notifications for rescued exceptions?Edit: You have to explicitly send notifications for rescued exceptions.