Agile Web Development

Build it. Launch it. Love it.

Exception Notifier

The Exception Notifier plugin provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application. The plugin is configurable, allowing programmers to specify:

  • the sender address of the email
  • the recipient addresses
  • the text used to prefix the subject line

The email includes information about the current request, session, and environment, and also gives a backtrace of the exception.

Vitals

Home http://github.com/rails/exception_notification/tree/master
Repository git://github.com/rails/exception_notification.git
License Rails' (MIT)
Tags Tag_red abcd ballsack email error exception exception helped_me_a_alot log mailer nbnb Notifier notify performance pretty_cool rail stack stacktrace trace
Rating (125 votes)
Created 18 May 2006

Comments

  • Avatar
    Andrew Selder
    18 January 2007

    This seems to break on Rails 1.2:

    I keep getting the following error message: Expected /Users/aselder/BostonLogic/match/config/../vendor/plugins/exception_notification/lib/exception_notifier.rb to define ExceptionNotifier

  • Rene Perrier
    21 February 2007

    Same problem with Rails 1.2 this article (http://www.mathewabonyi.com/articles/2007/02/18/initial-reactions-to-rails-12-annoyed/) talks about it, but does not really offer a solution

  • Avatar
    labrat
    15 April 2007

    You can get an updated version of this that should work with Rails 1.2 from the Caboo.se sample app.

    http://sample.caboo.se/

  • Avatar
    6 May 2007

    Thanks for a highly useful plugin.

    I'm using Rails 1.2.3 and the plugin works just fine.

  • Avatar
    Brandon Keene
    9 May 2007

    Note, this plugin hooks into ActionController::rescue_action_in_public()

    If you're working in your development environment or on your local machine, this won't be called and the plugin won't send e-mail.

    If you want to just try this out, throw this line at the bottom of app/controllers/application.rb:

    alias :rescue_action_locally :rescue_action_in_public

    Assume you can send mail and you configured the plugin, voila! It works in development.

  • Avatar
    Brett Neumeier
    12 October 2007

    In ruby 1.8.6p111, rendering the _environment.rhtml plugin fails with "TemplateError: flag after width". This is fixed if you change the string "%-s" to "%-s" on line three of the template.

  • Chris
    18 October 2007

    This is the correct string: "%-*s:"

  • Jean-Michel
    3 December 2007

    To test under development mode, add alias :rescue_action_locally :rescue_action_in_public in your ApplicationController (don't know why the underscore dissapear when copy-pasted!)

  • Avatar
    10 January 2008

    I was having trouble with it in a project, and found this: http://dev.rubyonrails.org/ticket/9940

    Then it began working for me!

  • Avatar
    William Evanson
    21 January 2008

    I keep getting a warning starting up my rails application warning: already initialized constant VIEW_PATH warning: already initialized constant APP_PATH warning: already initialized constant PARAM_FILTER_REPLACEMENT

    It started when I moved my app from 1.1.6 to 1.2.3.

  • Avatar
    Wakazula
    25 January 2008

    Hello.

    For the life of me, I cannot get the Exception Notification plugin to send email when in development mode. When tracing with the debugger it seems that no exception handlers are regsitered [rescue.rb: if rescue_action_with_handler(exception)]. As a result, ExceptionNotifiable.rescue_action_in_public never executes.

    If you have any thoughts, I'd love to hear them.

    NOTES - I'm running Rails 2.0.2 - I've restarted Webrick several times - for testing purposes, I'm forcing rails to throw a NameError exception - I know ActionMailer has been setup properly as I can send mail through it.

    [environment.rb]

    Rails::Initializer.run do |config| config.action_controller.consider_all_requests_local = false end

    ExceptionNotifier.exception_recipients = %w(u...@website.com) ExceptionNotifier.sender_address = %w(serv...@website.com)

    [application.rb]

    class ApplicationController < ActionController::Base include ExceptionNotifiable local_addresses.clear end

  • Avatar
    Sandeep
    3 July 2008

    I recently upgraded my app to rail 2.1 . I was running it in 1.2.3 all while.

    I hit this error: ActionView::TemplateFinder::InvalidViewPath (Unprocessed view path found: ... vendor/plugins/exception_notification/lib/../views"

    Has any faced this? How do I solve it?

    Thanks in Advance, Sandeep G

  • Avatar
    Björn
    6 August 2008

    Sandeep: I'm having the exact same problem. Anyone have a solution?

  • Avatar
    Walter
    19 August 2008

    This seems to get it going again in 2.1.

    In ExceptionNotifiable there is a template_root method. Change "def template_root" to "self.template_root =", and remove the "end".

    Sorry to be so elliptical, but this comment system obviously eats Ruby syntax for breakfast... :)

  • Avatar
    Stan Gudo
    20 August 2008

    I'm seeing the same problem as reported by Sandeep, can't seem to get it fixed. Any help appreciated. Thanks.

  • Avatar
    Darell
    28 August 2008

    To fix this plugin for rails 2.1 go to class ExceptionNotifier, comment out the template root function and add template_root= "#{File.dirname(FILE)}/../views" as the first line of the exception_notification function.

  • Avatar
    9 December 2008

    Must have plugin for applications that were recently deployed and could have some bugs ;)

  • Vijay
    21 January 2009

    Just installed the latest on GIT in Rails 2.2.2. This seems to break setting exception_recipients in production.rb, as it appears the vendor plugins get loaded after production.rb is processed and the require 'reinitializes' the ExceptionNotifier class a second time (resulting in the exception_recipients being reinitialized). A Workaround is to configure exception_notifier in a file in the initializers directory, but I'd be interested in knowing what the 'right' way to do this. (Rails 2.2.2/OSX 10.5)

Add a comment