Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Update and rename README to README.md #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 36 additions & 31 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Exception Notifier Plugin for Rails
# 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
Expand All @@ -11,60 +11,65 @@ application. The plugin is configurable, allowing programmers to specify:
The email includes information about the current request, session, and
environment, and also gives a backtrace of the exception.

== Usage
## Usage

As of Rails 3 ExceptionNotifier is used as a rack middleware

Whatever::Application.config.middleware.use ExceptionNotifier,
:email_prefix => "[Whatever] ",
:sender_address => %{"notifier" <[email protected]>},
:exception_recipients => %w{[email protected]}
```
Whatever::Application.config.middleware.use ExceptionNotifier,
:email_prefix => "[Whatever] ",
:sender_address => %{"notifier" <[email protected]>},
:exception_recipients => %w{[email protected]}
```

== Customization
## 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
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
* `@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
(wherever 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

```
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.

== Notification
## Notification

After an exception notification has been delivered the rack environment variable
'exception_notifier.delivered' will be set to +true+.

== Rails 2.3 stable and earlier
## Rails 2.3 stable and earlier

If you are running Rails 2.3 then see the branch for that:

Expand All @@ -74,8 +79,8 @@ If you are running pre-rack Rails then see this tag:

http://github.com/rails/exception_notification/tree/pre-2-3

== Support and tickets
##Support and tickets

https://rails.lighthouseapp.com/projects/8995-rails-plugins

Copyright (c) 2005 Jamis Buck, released under the MIT license
Copyright (c) 2005 Jamis Buck, released under the MIT license