github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

rails / exception_notification

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 585
    • 77
  • Source
  • Commits
  • Network (77)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Exception Notifier Plugin for Rails — Read more

  cancel

http://rubyonrails.org

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Ignore common 404ish exceptions 
josh (author)
Tue Jan 26 08:15:56 -0800 2010
commit  14f347ee5517049669c690f8e1dd33f1385b3319
tree    6922e68e491fc082bc2e44aec72edb66be7166fb
parent  d68b14b0f2fc6c3cdeb81374bdf7d5b53edec809
exception_notification /
name age
history
message
file README Fri Jan 22 08:47:02 -0800 2010 Refactor exception notifier for Rails 3 [josh]
directory lib/ Tue Jan 26 08:15:56 -0800 2010 Ignore common 404ish exceptions [josh]
README
= Exception Notifier Plugin for Rails

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.

== Usage

First, include the ExceptionNotifiable mixin in whichever controller you want
to generate error emails (typically ApplicationController):

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

Then, specify the email recipients in your environment:

  ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bill@schmoe.com)

And that's it! The defaults take care of the rest.

== Configuration

You can tweak other values to your liking, as well. In your environment file,
just set any or all of the following values:

  # defaults to exception.notifier@default.com
  ExceptionNotifier.sender_address =
    %("Application Error" <app.error@myapp.com>)

  # defaults to "[ERROR] "
  ExceptionNotifier.email_prefix = "[APP] "


== Customization

By default, the notification email includes four parts: request, session,
environment, and backtrace (in that order). You can customize how each of those
sections are rendered by placing a partial named for that part in your
app/views/exception_notifier directory (e.g., _session.rhtml). Each partial has
access to the following variables:

* @controller: the controller that caused the error
* @request: the current request object
* @exception: the exception that was raised
* @backtrace: a sanitized version of the exception's backtrace
* @data: a hash of optional data values that were passed to the notifier
* @sections: the array of sections to include in the email

You can reorder the sections, or exclude sections completely, by altering the
ExceptionNotifier.sections variable. You can even add new sections that
describe application-specific data--just add the section's name to the list
(whereever you'd like), and define the corresponding partial. Then, if your
new section requires information that isn't available by default, make sure
it is made available to the email using the exception_data macro:

  class ApplicationController < ActionController::Base
    before_filter :log_additional_data
    ...
    protected
      def log_additional_data
        request.env["exception_notifier.exception_data"] = {
          :document => @document,
          :person => @person
        }
      end
    ...
  end

In the above case, @document and @person would be made available to the email
renderer, allowing your new section(s) to access and display them. See the
existing sections defined by the plugin for examples of how to write your own.


Copyright (c) 2005 Jamis Buck, released under the MIT license
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server