1- = Exception Notifier Plugin for Rails
1+ Exception Notifier Plugin for Rails
2+ ====
23
34The Exception Notifier plugin provides a mailer object and a default set of
45templates for sending email notifications when errors occur in a Rails
@@ -11,29 +12,31 @@ application. The plugin is configurable, allowing programmers to specify:
1112The email includes information about the current request, session, and
1213environment, and also gives a backtrace of the exception.
1314
14- == Usage
15+ Usage
16+ ---
1517
1618As of Rails 3 ExceptionNotifier is used as a rack middleware
1719
18- Whatever::Application.config.middleware.use ExceptionNotifier,
19- :email_prefix => "[Whatever] ",
20- :sender_address => %{"notifier" <
[email protected] >},
21- :exception_recipients => %w{
[email protected] }
20+ Whatever::Application.config.middleware.use ExceptionNotifier,
21+ :email_prefix => "[Whatever] ",
22+ :sender_address => %{"notifier" <[email protected] >}, 23+ :exception_recipients => %w{[email protected] } 2224
23- == Customization
25+ Customization
26+ ---
2427
2528By default, the notification email includes four parts: request, session,
2629environment, and backtrace (in that order). You can customize how each of those
2730sections are rendered by placing a partial named for that part in your
2831app/views/exception_notifier directory (e.g., _ session.rhtml). Each partial has
2932access to the following variables:
3033
31- * @controller: the controller that caused the error
32- * @request: the current request object
33- * @exception: the exception that was raised
34- * @backtrace: a sanitized version of the exception's backtrace
35- * @data: a hash of optional data values that were passed to the notifier
36- * @sections: the array of sections to include in the email
34+ @controller # the controller that caused the error
35+ @request # the current request object
36+ @exception # the exception that was raised
37+ @backtrace # a sanitized version of the exception's backtrace
38+ @data # a hash of optional data values that were passed to the notifier
39+ @sections # the array of sections to include in the email
3740
3841You can reorder the sections, or exclude sections completely, by altering the
3942ExceptionNotifier.sections variable. You can even add new sections that
@@ -42,40 +45,43 @@ describe application-specific data--just add the section's name to the list
4245new section requires information that isn't available by default, make sure
4346it is made available to the email using the exception_data macro:
4447
45- class ApplicationController < ActionController::Base
46- before_filter :log_additional_data
47- ...
48- protected
49- def log_additional_data
50- request.env["exception_notifier.exception_data"] = {
51- :document => @document,
52- :person => @person
53- }
54- end
55- ...
56- end
48+ class ApplicationController < ActionController::Base
49+ before_filter :log_additional_data
50+ ...
51+ protected
52+ def log_additional_data
53+ request.env["exception_notifier.exception_data"] = {
54+ :document => @document,
55+ :person => @person
56+ }
57+ end
58+ ...
59+ end
5760
5861In the above case, @document and @person would be made available to the email
5962renderer, allowing your new section(s) to access and display them. See the
6063existing sections defined by the plugin for examples of how to write your own.
6164
62- == Notification
65+ Notification
66+ ---
6367
6468After an exception notification has been delivered the rack environment variable
6569'exception_notifier.delivered' will be set to +true+.
6670
67- == Rails 2.3 stable and earlier
71+ Rails 2.3 stable and earlier
72+ ---
6873
6974If you are running Rails 2.3 then see the branch for that:
7075
71- http://github.com/rails/exception_notification/tree/2-3-stable
76+ < a href = " http://github.com/rails/exception_notification/tree/2-3-stable " > http://github.com/rails/exception_notification/tree/2-3-stable </ a >
7277
7378If you are running pre-rack Rails then see this tag:
7479
75- http://github.com/rails/exception_notification/tree/pre-2-3
80+ < a href = " http://github.com/rails/exception_notification/tree/pre-2-3 " > http://github.com/rails/exception_notification/tree/pre-2-3 </ a >
7681
77- == Support and tickets
82+ Support and tickets
83+ ---
7884
79- https://github.com/smartinez87/exception_notification/issues
85+ < a href = " https://github.com/smartinez87/exception_notification/issues " > https://github.com/smartinez87/exception_notification/issues </ a >
8086
8187Copyright (c) 2005 Jamis Buck, released under the MIT license
0 commit comments