summaryrefslogtreecommitdiff
path: root/vendor/plugins/exception_notification/README
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-10-31 18:59:01 +0100
committerhukl <contact@smyck.org>2009-10-31 18:59:01 +0100
commita2671e54c3abfcdc14b95f262d0bb6d016a938ff (patch)
tree36fb152b93ac11fe2c97b91f6fde5b39408eed15 /vendor/plugins/exception_notification/README
parent3781bd31ff137e6bc0a3b1d0c5506dfb42878a5c (diff)
added exception notifier plugin to catch all exceptions
Diffstat (limited to 'vendor/plugins/exception_notification/README')
-rw-r--r--vendor/plugins/exception_notification/README111
1 files changed, 111 insertions, 0 deletions
diff --git a/vendor/plugins/exception_notification/README b/vendor/plugins/exception_notification/README
new file mode 100644
index 0000000..9a47c41
--- /dev/null
+++ b/vendor/plugins/exception_notification/README
@@ -0,0 +1,111 @@
1= Exception Notifier Plugin for Rails
2
3The Exception Notifier plugin provides a mailer object and a default set of
4templates for sending email notifications when errors occur in a Rails
5application. The plugin is configurable, allowing programmers to specify:
6
7* the sender address of the email
8* the recipient addresses
9* the text used to prefix the subject line
10
11The email includes information about the current request, session, and
12environment, and also gives a backtrace of the exception.
13
14== Usage
15
16First, include the ExceptionNotifiable mixin in whichever controller you want
17to generate error emails (typically ApplicationController):
18
19 class ApplicationController < ActionController::Base
20 include ExceptionNotifiable
21 ...
22 end
23
24Then, specify the email recipients in your environment:
25
26 ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bill@schmoe.com)
27
28And that's it! The defaults take care of the rest.
29
30== Configuration
31
32You can tweak other values to your liking, as well. In your environment file,
33just set any or all of the following values:
34
35 # defaults to exception.notifier@default.com
36 ExceptionNotifier.sender_address =
37 %("Application Error" <app.error@myapp.com>)
38
39 # defaults to "[ERROR] "
40 ExceptionNotifier.email_prefix = "[APP] "
41
42Email notifications will only occur when the IP address is determined not to
43be local. You can specify certain addresses to always be local so that you'll
44get a detailed error instead of the generic error page. You do this in your
45controller (or even per-controller):
46
47 consider_local "64.72.18.143", "14.17.21.25"
48
49You can specify subnet masks as well, so that all matching addresses are
50considered local:
51
52 consider_local "64.72.18.143/24"
53
54The address "127.0.0.1" is always considered local. If you want to completely
55reset the list of all addresses (for instance, if you wanted "127.0.0.1" to
56NOT be considered local), you can simply do, somewhere in your controller:
57
58 local_addresses.clear
59
60== Customization
61
62By default, the notification email includes four parts: request, session,
63environment, and backtrace (in that order). You can customize how each of those
64sections are rendered by placing a partial named for that part in your
65app/views/exception_notifier directory (e.g., _session.rhtml). Each partial has
66access to the following variables:
67
68* @controller: the controller that caused the error
69* @request: the current request object
70* @exception: the exception that was raised
71* @host: the name of the host that made the request
72* @backtrace: a sanitized version of the exception's backtrace
73* @rails_root: a sanitized version of RAILS_ROOT
74* @data: a hash of optional data values that were passed to the notifier
75* @sections: the array of sections to include in the email
76
77You can reorder the sections, or exclude sections completely, by altering the
78ExceptionNotifier.sections variable. You can even add new sections that
79describe application-specific data--just add the section's name to the list
80(whereever you'd like), and define the corresponding partial. Then, if your
81new section requires information that isn't available by default, make sure
82it is made available to the email using the exception_data macro:
83
84 class ApplicationController < ActionController::Base
85 ...
86 protected
87 exception_data :additional_data
88
89 def additional_data
90 { :document => @document,
91 :person => @person }
92 end
93 ...
94 end
95
96In the above case, @document and @person would be made available to the email
97renderer, allowing your new section(s) to access and display them. See the
98existing sections defined by the plugin for examples of how to write your own.
99
100== Advanced Customization
101
102By default, the email notifier will only notify on critical errors. For
103ActiveRecord::RecordNotFound and ActionController::UnknownAction, it will
104simply render the contents of your public/404.html file. Other exceptions
105will render public/500.html and will send the email notification. If you want
106to use different rules for the notification, you will need to implement your
107own rescue_action_in_public method. You can look at the default implementation
108in ExceptionNotifiable for an example of how to go about that.
109
110
111Copyright (c) 2005 Jamis Buck, released under the MIT license \ No newline at end of file