super_exception_notifier 3.0.6 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +15 -0
- data/README +28 -452
- data/VERSION.yml +1 -1
- data/lib/exception_notification/deprecated_methods.rb +1 -1
- data/lib/exception_notification/exception_notifiable.rb +74 -35
- data/lib/exception_notification/notifiable.rb +7 -6
- data/lib/exception_notification/notifiable_helper.rb +16 -16
- data/lib/exception_notification/notifier.rb +6 -6
- data/lib/views/exception_notification/notifier/_backtrace.html.erb +1 -0
- data/lib/views/exception_notification/notifier/_environment.html.erb +14 -0
- data/lib/views/exception_notification/notifier/_inspect_model.html.erb +16 -0
- data/lib/views/exception_notification/notifier/_request.html.erb +8 -0
- data/lib/views/exception_notification/notifier/_session.html.erb +6 -0
- data/lib/views/exception_notification/notifier/_title.html.erb +3 -0
- data/lib/views/exception_notification/notifier/background_exception_notification.text.plain.erb +10 -0
- data/lib/views/exception_notification/notifier/rake_exception_notification.text.plain.erb +6 -0
- data/super_exception_notifier.gemspec +14 -5
- metadata +29 -4
data/CHANGELOG.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
2009-01-28 v2.0.8
|
2
|
+
- improve readme
|
3
|
+
|
4
|
+
2009-12-30 v2.0.7
|
5
|
+
- cite /rails/app/views/exception_notifiable/500.html in Rakefile (oops!)
|
6
|
+
|
7
|
+
2009-12-30 v2.0.6
|
8
|
+
- cite /rails/app/views/exception_notifiable/500.html in gemspec (oops!)
|
9
|
+
|
10
|
+
2009-12-30 v2.0.5
|
11
|
+
- use blank? instead of empty? so nils won't cause an error
|
12
|
+
|
13
|
+
2009-11-04
|
14
|
+
* Fixing Typos in Comments and Readme
|
15
|
+
* General Readme cleanup
|
data/README
CHANGED
@@ -22,13 +22,10 @@ allowing programmers to customize (settings are per environment or per class):
|
|
22
22
|
* Hooks into other website services (e.g. you can send exceptions to to Switchub.com)
|
23
23
|
* Specify which level of notification you would like with an array of optional styles of notification:
|
24
24
|
[:render, :email, :web_hooks]
|
25
|
-
|
26
|
-
New features for 2.0.x:
|
27
|
-
|
28
25
|
* Can notify of errors occurring in any method in any class in Ruby by wrapping the method call like this:
|
29
26
|
notifiable { method }
|
30
27
|
* Can notify of errors in Rake tasks using 'NotifiedTask.new' instead of 'task' when writing tasks
|
31
|
-
|
28
|
+
* Works with Hoptoad Notifier, so you can notify via SEN and/or Hoptoad for any particular errors.
|
32
29
|
The email includes information about the current request, session, and
|
33
30
|
environment, and also gives a backtrace of the exception.
|
34
31
|
|
@@ -54,105 +51,57 @@ This fork of Exception Notifier is in production use on several large websites (
|
|
54
51
|
|
55
52
|
[sudo] gem install super_exception_notifier
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
Use Git to build from source:
|
60
|
-
|
61
|
-
mkdir -p ~/src
|
62
|
-
cd ~/src
|
63
|
-
git clone git://github.com/pboling/exception_notification.git
|
64
|
-
cd exception_notification
|
65
|
-
gem build exception_notification.gemspec
|
66
|
-
sudo gem install super_exception_notification-2.0.0.gem # (Or whatever version gets built)
|
67
|
-
|
68
|
-
Then cd to your rails app to optionally freeze the gem into your app:
|
69
|
-
|
70
|
-
rake gems:freeze GEM=super_exception_notifier
|
54
|
+
More Installation Options are here: http://wiki.github.com/pboling/exception_notification/installation
|
71
55
|
|
72
|
-
==
|
56
|
+
== Configuration as RubyGem
|
73
57
|
|
74
|
-
|
58
|
+
config.gem 'super_exception_notifier', :lib => "exception_notification"
|
75
59
|
|
76
|
-
|
60
|
+
More Configuration Options are here: http://wiki.github.com/pboling/exception_notification/configuration
|
77
61
|
|
78
|
-
==
|
79
|
-
|
80
|
-
If installed as a gem, in your environment.rb:
|
81
|
-
|
82
|
-
config.gem 'super_exception_notifier',
|
83
|
-
:version => '~> 2.0.0',
|
84
|
-
:lib => "exception_notifier" #The :lib declaration is required!
|
85
|
-
|
86
|
-
== Basic Environment Configuration
|
87
|
-
|
88
|
-
These are settings that are global for SEN wherever it is used in your project.
|
89
|
-
You can tweak other values to your liking, as well. In your environment file or initializer,
|
90
|
-
just set any or all of the following values (defaults are shown):
|
62
|
+
== Configuration In Environment (Initializer)
|
91
63
|
|
92
64
|
ExceptionNotification::Notifier.configure_exception_notifier do |config|
|
93
|
-
# If left empty web hooks will not be engaged
|
94
|
-
config[:web_hooks] = []
|
95
65
|
config[:app_name] = "[MYAPP]"
|
96
66
|
config[:sender_address] = "super.exception.notifier@example.com"
|
97
|
-
config[:exception_recipients] = []
|
98
|
-
# Customize the subject line
|
99
|
-
config[:subject_prepend] = "[#{(defined?(Rails) ? Rails.env : RAILS_ENV).capitalize} ERROR] "
|
100
|
-
config[:subject_append] = nil
|
101
|
-
# Include which sections of the exception email?
|
102
|
-
config[:sections] = %w(request session environment backtrace)
|
67
|
+
config[:exception_recipients] = [] # You need to set at least one recipient if you want to get the notifications
|
103
68
|
# In a local environment only use this gem to render, never email
|
104
69
|
#defaults to false - meaning by default it sends email. Setting true will cause it to only render the error pages, and NOT email.
|
105
70
|
config[:skip_local_notification] = true
|
106
|
-
# Example:
|
107
|
-
#config[:view_path] = 'app/views/error'
|
108
|
-
config[:view_path] = nil
|
109
71
|
# Error Notification will be sent if the HTTP response code for the error matches one of the following error codes
|
110
72
|
config[:notify_error_codes] = %W( 405 500 503 )
|
111
|
-
# Error Notification will be sent if the error class matches one of the following error
|
73
|
+
# Error Notification will be sent if the error class matches one of the following error classes
|
112
74
|
config[:notify_error_classes] = %W( )
|
113
75
|
# What should we do for errors not listed?
|
114
76
|
config[:notify_other_errors] = true
|
115
77
|
# If you set this SEN will attempt to use git blame to discover the person who made the last change to the problem code
|
116
78
|
config[:git_repo_path] = nil # ssh://git@blah.example.com/repo/webapp.git
|
117
|
-
#This is the template root for the exception notification emails. If you want to use your own set your own path.
|
118
|
-
#config[:template_root] = "#{File.dirname(__FILE__)}/../views"
|
119
79
|
end
|
120
80
|
|
121
|
-
|
122
|
-
|
123
|
-
You may use SEN to send information about exceptions that
|
124
|
-
occur while running application scripts without a controller. Simply wrap the
|
125
|
-
code you want to watch with the notifiable method:
|
126
|
-
|
127
|
-
/PATH/TO/APP/script/runner -e production "notifiable { run_billing }"
|
128
|
-
|
129
|
-
Or from the console:
|
81
|
+
More Configuration Options: http://wiki.github.com/pboling/exception_notification/advanced-environment-configuration
|
130
82
|
|
131
|
-
|
83
|
+
== Handling Errors in Request Cycle
|
132
84
|
|
133
|
-
|
134
|
-
|
135
|
-
Use 'NotifiedTask.new' instead of 'task':
|
136
|
-
|
137
|
-
NotifiedTask.new :sometask => :environment do
|
138
|
-
puts "I'm a task"
|
139
|
-
end
|
140
|
-
|
141
|
-
== Exceptions Within a Controller
|
142
|
-
|
143
|
-
1. Include the ExceptionNotifiable mixin in whichever controller you want
|
144
|
-
to generate error emails (typically ApplicationController):
|
85
|
+
1. Include the ExceptionNotification::ExceptionNotifiable mixin in whichever controller you want to generate error emails (typically ApplicationController):
|
145
86
|
|
146
87
|
class ApplicationController < ActionController::Base
|
147
|
-
|
88
|
+
############################################################
|
89
|
+
# ERROR HANDLING et Foo
|
90
|
+
include ExceptionNotification::ExceptionNotifiable
|
148
91
|
#Comment out the line below if you want to see the normal rails errors in normal development.
|
149
92
|
alias :rescue_action_locally :rescue_action_in_public if Rails.env == 'development'
|
150
93
|
#self.error_layout = 'errors'
|
151
|
-
|
94
|
+
self.exception_notifiable_verbose = true #SEN uses logger.info, so won't be verbose in production
|
95
|
+
self.exception_notifiable_pass_through = :hoptoad # requires the standard hoptoad gem to be installed, and setup normally
|
96
|
+
self.exception_notifiable_silent_exceptions = [Acl9::AccessDenied, MethodDisabled, ActionController::RoutingError ]
|
97
|
+
#specific errors can be handled by something else:
|
98
|
+
rescue_from 'Acl9::AccessDenied', :with => :access_denied
|
99
|
+
# END ERROR HANDLING
|
100
|
+
############################################################
|
152
101
|
...
|
153
102
|
end
|
154
|
-
|
155
|
-
2. Specify the email recipients in your environment:
|
103
|
+
|
104
|
+
2. Specify the email recipients in your environment (You should have already done this in the "Configuration in Environment (Initializer)" step above):
|
156
105
|
|
157
106
|
ExceptionNotification::Notifier.configure_exception_notifier do |config|
|
158
107
|
config[:exception_recipients] = %w(joe@example.com bill@example.com)
|
@@ -160,385 +109,12 @@ to generate error emails (typically ApplicationController):
|
|
160
109
|
|
161
110
|
3. Make sure you have your ActionMailer server settings correct if you are using the e-mail features.
|
162
111
|
|
163
|
-
4. That
|
164
|
-
|
165
|
-
== Basic Controller Configuration
|
166
|
-
|
167
|
-
In any controller you do this:
|
168
|
-
include ExceptionNotifiable
|
169
|
-
|
170
|
-
Then that controller (or all of them if you put it in the application controller) will have its errors handled by SEN.
|
171
|
-
You can customize how each controller handles exceptions on a per controller basis, or all together in the application controller.
|
172
|
-
The available configuration options are shown with their default settings, pulled from the gem's source:
|
173
|
-
|
174
|
-
# HTTP status codes and what their 'English' status message is
|
175
|
-
self.http_status_codes = {
|
176
|
-
"400" => "Bad Request",
|
177
|
-
"403" => "Forbidden",
|
178
|
-
"404" => "Not Found",
|
179
|
-
"405" => "Method Not Allowed",
|
180
|
-
"410" => "Gone",
|
181
|
-
"418" => "I'm a teapot",
|
182
|
-
"422" => "Unprocessable Entity",
|
183
|
-
"423" => "Locked",
|
184
|
-
"500" => "Internal Server Error",
|
185
|
-
"501" => "Not Implemented",
|
186
|
-
"503" => "Service Unavailable"
|
187
|
-
}
|
188
|
-
|
189
|
-
# error_layout:
|
190
|
-
# can be defined at controller level to the name of the desired error layout,
|
191
|
-
# or set to true to render the controller's own default layout,
|
192
|
-
# or set to false to render errors with no layout
|
193
|
-
# syntax is the same as the rails 'layout' method (which is to say a string)
|
194
|
-
self.error_layout = nil
|
195
|
-
|
196
|
-
# Rails error classes to rescue and how to rescue them (which error code to use)
|
197
|
-
self.error_class_status_codes = {
|
198
|
-
# These are standard errors in rails / ruby
|
199
|
-
NameError => "503",
|
200
|
-
TypeError => "503",
|
201
|
-
RuntimeError => "500",
|
202
|
-
# These are custom error names defined in lib/super_exception_notifier/custom_exception_classes
|
203
|
-
AccessDenied => "403",
|
204
|
-
PageNotFound => "404",
|
205
|
-
InvalidMethod => "405",
|
206
|
-
ResourceGone => "410",
|
207
|
-
CorruptData => "422",
|
208
|
-
NoMethodError => "500",
|
209
|
-
NotImplemented => "501",
|
210
|
-
MethodDisabled => "200"
|
211
|
-
}
|
212
|
-
|
213
|
-
# Highly dependent on the version of rails, so we're very protective about these'
|
214
|
-
self.error_class_status_codes.merge!({ ActionView::TemplateError => "500"}) if defined?(ActionView) && ActionView.const_defined?(:TemplateError)
|
215
|
-
self.error_class_status_codes.merge!({ ActiveRecord::RecordNotFound => "400" }) if defined?(ActiveRecord) && ActiveRecord.const_defined?(:RecordNotFound)
|
216
|
-
self.error_class_status_codes.merge!({ ActiveResource::ResourceNotFound => "404" }) if defined?(ActiveResource) && ActiveResource.const_defined?(:ResourceNotFound)
|
217
|
-
|
218
|
-
if defined?(ActionController)
|
219
|
-
self.error_class_status_codes.merge!({ ActionController::UnknownController => "404" }) if ActionController.const_defined?(:UnknownController)
|
220
|
-
self.error_class_status_codes.merge!({ ActionController::MissingTemplate => "404" }) if ActionController.const_defined?(:MissingTemplate)
|
221
|
-
self.error_class_status_codes.merge!({ ActionController::MethodNotAllowed => "405" }) if ActionController.const_defined?(:MethodNotAllowed)
|
222
|
-
self.error_class_status_codes.merge!({ ActionController::UnknownAction => "501" }) if ActionController.const_defined?(:UnknownAction)
|
223
|
-
self.error_class_status_codes.merge!({ ActionController::RoutingError => "404" }) if ActionController.const_defined?(:RoutingError)
|
224
|
-
self.error_class_status_codes.merge!({ ActionController::InvalidAuthenticityToken => "405" }) if ActionController.const_defined?(:InvalidAuthenticityToken)
|
225
|
-
end
|
226
|
-
|
227
|
-
# Verbosity of the gem (true or false) mainly useful for debugging
|
228
|
-
self.exception_notifiable_verbose = false
|
229
|
-
|
230
|
-
# Do Not Ever send error notification emails for these Error Classes
|
231
|
-
self.exception_notifiable_silent_exceptions = []
|
232
|
-
self.exception_notifiable_silent_exceptions << ActiveRecord::RecordNotFound if defined?(ActiveRecord)
|
233
|
-
if defined?(ActionController)
|
234
|
-
self.exception_notifiable_silent_exceptions << ActionController::UnknownController
|
235
|
-
self.exception_notifiable_silent_exceptions << ActionController::UnknownAction
|
236
|
-
self.exception_notifiable_silent_exceptions << ActionController::RoutingError
|
237
|
-
self.exception_notifiable_silent_exceptions << ActionController::MethodNotAllowed
|
238
|
-
end
|
239
|
-
|
240
|
-
# Notification Level
|
241
|
-
# Web Hooks, even though they are turned on by default, only get used if you actually configure them in the environment (see above)
|
242
|
-
# Email, even though it is turned on by default, only gets used if you actually configure recipients in the environment (see above)
|
243
|
-
self.exception_notifiable_notification_level = [:render, :email, :web_hooks]
|
244
|
-
|
245
|
-
== Environmental Behavior
|
246
|
-
|
247
|
-
Email notifications will only occur when the IP address is determined not to
|
248
|
-
be local. You can specify certain addresses to always be local so that you'll
|
249
|
-
get a detailed error instead of the generic error page. You do this in your
|
250
|
-
controller (or even per-controller):
|
251
|
-
|
252
|
-
consider_local "64.72.18.143", "14.17.21.25"
|
253
|
-
|
254
|
-
You can specify subnet masks as well, so that all matching addresses are
|
255
|
-
considered local:
|
256
|
-
|
257
|
-
consider_local "64.72.18.143/24"
|
258
|
-
|
259
|
-
The address "127.0.0.1" is always considered local. If you want to completely
|
260
|
-
reset the list of all addresses (for instance, if you wanted "127.0.0.1" to
|
261
|
-
NOT be considered local), you can simply do, somewhere in your controller:
|
262
|
-
|
263
|
-
local_addresses.clear
|
264
|
-
|
265
|
-
== Error Layout Customization
|
266
|
-
|
267
|
-
SEN allows you to specify the layout for errors at several levels:
|
268
|
-
|
269
|
-
* all errors use same layout site-wide
|
270
|
-
* customize a single controller
|
271
|
-
* can use the same layout as the controller
|
272
|
-
* no layout at all
|
273
|
-
|
274
|
-
By default it will render the error with the layout the controller is using. You just need to set in application.rb (assuming you included ExceptionNotifiable in applicaiton.rb) (or per-controller):
|
275
|
-
|
276
|
-
# All Same site-wide (in application.rb)
|
277
|
-
self.error_layout = 'my_error_layout'
|
278
|
-
# customize a single controller
|
279
|
-
self.error_layout = 'example_controller_error_layout'
|
280
|
-
# Same layout as the current controller is using
|
281
|
-
self.error_layout = true
|
282
|
-
# No layout at all
|
283
|
-
self.error_layout = false
|
284
|
-
|
285
|
-
SuperExceptionNotifier allows customization of the error classes that will be handled, and which HTTP status codes they will be handled as: (default values are shown)
|
286
|
-
Example in application.rb or on a per-controller basis:
|
287
|
-
|
288
|
-
self.http_status_codes = { "200" => "OK"
|
289
|
-
"400" => "Bad Request",
|
290
|
-
"403" => "Forbidden",
|
291
|
-
"404" => "Not Found",
|
292
|
-
"405" => "Method Not Allowed",
|
293
|
-
"410" => "Gone",
|
294
|
-
"500" => "Internal Server Error",
|
295
|
-
"501" => "Not Implemented",
|
296
|
-
"503" => "Service Unavailable" }
|
297
|
-
|
298
|
-
Q: Why is "200" listed as an error code?
|
299
|
-
|
300
|
-
A: You may want to have multiple custom errors that the standard HTTP status codes weren't designed to accommodate, and for which you need to render customized pages. Explanation and examples are a little further down...
|
301
|
-
|
302
|
-
Then you can specify which of those should send out emails!
|
303
|
-
By default, the email notifier will only notify on critical errors (405 500 503 statuses).
|
304
|
-
For example, ActiveRecord::RecordNotFound and ActionController::UnknownAction errors will simply render the contents of #{this gem's root}/rails/app/views/exception_notifiable/###.html file, where ### is 400 and 501 respectively.
|
305
|
-
|
306
|
-
ExceptionNotification::Notifier.config[:send_email_error_codes] = %w( 400 405 500 503 )
|
307
|
-
|
308
|
-
You can also configure the text of the HTTP request's response status code: (by default only the last 6 will be handled, the first 6 are made up error classes)
|
309
|
-
Example in application.rb or on a per-controller basis:
|
310
|
-
|
311
|
-
self.error_class_status_codes = {
|
312
|
-
NameError => "503",
|
313
|
-
TypeError => "503",
|
314
|
-
ActiveRecord::RecordNotFound => "400",
|
315
|
-
}
|
316
|
-
|
317
|
-
To make up your own error classes, you can define them in environment.rb, or in application.rb, or wherever you need them.
|
318
|
-
These are defined by the gem and are available to you in controllers once ExceptionNotifiable is included in application.rb or the current controller:
|
319
|
-
|
320
|
-
class AccessDenied < StandardError; end
|
321
|
-
class ResourceGone < StandardError; end
|
322
|
-
class NotImplemented < StandardError; end
|
323
|
-
class PageNotFound < StandardError; end
|
324
|
-
class InvalidMethod < StandardError; end
|
325
|
-
class CorruptData < StandardError; end
|
326
|
-
class MethodDisabled < StandardError; end
|
327
|
-
|
328
|
-
Methods like this are also defined by the gem in super_exception_notifier/custom_exception_methods.rb:
|
329
|
-
def access_denied
|
330
|
-
raise AccessDenied
|
331
|
-
end
|
332
|
-
|
333
|
-
They can be used like this in a controller:
|
334
|
-
before_filter :owner_required
|
335
|
-
protected
|
336
|
-
def owner_required
|
337
|
-
access_denied unless current_user.id == @photo.user_id
|
338
|
-
end
|
339
|
-
public
|
340
|
-
#... rest of controller
|
341
|
-
|
342
|
-
You may also configure which HTTP status codes will send out email: (by default = [], email sending is defined by status code only)
|
343
|
-
|
344
|
-
ExceptionNotification::Notifier.config[:send_email_error_classes] = [
|
345
|
-
NameError,
|
346
|
-
TypeError,
|
347
|
-
ActionController::RoutingError
|
348
|
-
]
|
349
|
-
|
350
|
-
Email will be sent if the error matches one of the error classes to send email for OR if the error's assigned HTTP status code is configured to send email!
|
351
|
-
|
352
|
-
You can also customize what is rendered. SuperExceptionNotifier will render the first file it finds in this order:
|
353
|
-
|
354
|
-
#{RAILS_ROOT}/public/###.html
|
355
|
-
#{RAILS_ROOT}/#{ExceptionNotification::Notifier.config[:view_path]}/###.html
|
356
|
-
#{this gem's root}/rails/app/views/exception_notifiable/#{status_cd}.html
|
357
|
-
|
358
|
-
And if none of those paths has a valid file to render, this one wins:
|
359
|
-
|
360
|
-
#{this gem's root}/rails/app/views/exception_notifiable/500.html
|
361
|
-
|
362
|
-
You can configure ExceptionNotification::Notifier.config[:view_path] in your environment file like this:
|
363
|
-
|
364
|
-
ExceptionNotification::Notifier.config[:view_path] = 'app/views/error'
|
365
|
-
|
366
|
-
So public trumps your custom path which trumps the gem's default path.
|
367
|
-
|
368
|
-
== Custom Error Pages
|
369
|
-
|
370
|
-
You can render CUSTOM error pages! Here's how:
|
371
|
-
|
372
|
-
1. Make sure 200 is one of your status codes (optional)
|
373
|
-
* self.http_status_codes = { "200" => "OK" }
|
374
|
-
2. Setup your custom error class, e.g. in config/environment.rb:
|
375
|
-
* class InsufficientFundsForWithdrawal < StandardError; end
|
376
|
-
3. Setup SuperExceptionNotifier to handle the error, in app/controllers/application.rb:
|
377
|
-
* self.error_class_status_codes = { InsufficientFundsForWithdrawal => "200" }
|
378
|
-
4. Set your custom error's view path:
|
379
|
-
* ExceptionNotification::Notifier.config[:view_path] = 'app/views/error'
|
380
|
-
5. Create a view for the error. SuperExceptionNotifier munges the error's class by converting to a string and then replacing consecutive ':' with '' and then downcases it:
|
381
|
-
* touch app/views/error/insufficient_funds_for_withdrawal.html
|
382
|
-
6. If you want a custom layout (by default it will render the error with the layout the controller is using) you just need to set, in application.rb (or per-controller):
|
383
|
-
* self.error_layout = 'my_error_layout' #or = true for the same layout as the controller, or = false for no layout
|
384
|
-
7. That's it! All errors that are set to be handled with a status of "200" will render a custom page.
|
385
|
-
8. If you want to have errors that render custom pages also send emails then you'll need to:
|
386
|
-
* ExceptionNotification::Notifier.config[:send_email_error_classes] = [ InsufficientFundsForWithdrawal ]
|
387
|
-
|
388
|
-
== Customization
|
389
|
-
|
390
|
-
By default, the notification email includes four parts: request, session,
|
391
|
-
environment, and backtrace (in that order). You can customize how each of those
|
392
|
-
sections are rendered by placing a partial named for that part in your
|
393
|
-
app/views/exception_notifier directory (e.g., _session.rhtml). Each partial has
|
394
|
-
access to the following variables:
|
395
|
-
|
396
|
-
* @controller: the controller that caused the error
|
397
|
-
* @request: the current request object
|
398
|
-
* @exception: the exception that was raised
|
399
|
-
* @host: the name of the host that made the request
|
400
|
-
* @backtrace: a sanitized version of the exception's backtrace
|
401
|
-
* @rails_root: a sanitized version of RAILS_ROOT
|
402
|
-
* @data: a hash of optional data values that were passed to the notifier
|
403
|
-
* @sections: the array of sections to include in the email
|
404
|
-
|
405
|
-
You can reorder the sections, or exclude sections completely, by altering the
|
406
|
-
ExceptionNotification::Notifier.config[:sections] variable.
|
407
|
-
|
408
|
-
== Not working due to nature of gem vs plugin
|
409
|
-
|
410
|
-
This might work if you install the gem as a plugin.
|
411
|
-
|
412
|
-
You can even add new sections that describe application-specific data --
|
413
|
-
just add the section's name to the list (wherever you'd like), and define the
|
414
|
-
corresponding partial. Then, if your new section requires information that isn't
|
415
|
-
available by default, make sure it is made available to the email using the
|
416
|
-
exception_data macro:
|
417
|
-
|
418
|
-
class ApplicationController < ActionController::Base
|
419
|
-
...
|
420
|
-
protected
|
421
|
-
exception_data :additional_data
|
422
|
-
|
423
|
-
def additional_data
|
424
|
-
{ :document => @document,
|
425
|
-
:person => @person }
|
426
|
-
end
|
427
|
-
...
|
428
|
-
end
|
429
|
-
|
430
|
-
In the above case, @document and @person would be made available to the email
|
431
|
-
renderer, allowing your new section(s) to access and display them. See the
|
432
|
-
existing sections defined by the gem for examples of how to write your own.
|
433
|
-
|
434
|
-
== Advanced Customization
|
435
|
-
|
436
|
-
If you want to seriously modify the rules for the notification, you will need to implement your
|
437
|
-
own rescue_action_in_public method. You can look at the default implementation
|
438
|
-
in ExceptionNotifiable for an example of how to go about that.
|
439
|
-
|
440
|
-
== HTTP Error Codes Used by SEN by default
|
441
|
-
|
442
|
-
For reference these are the error codes that SEN can inherently handle, and they were gleaned from the following two websites.
|
443
|
-
Official w3.org HTTP 1.1 Error Codes:
|
444
|
-
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
445
|
-
Not all the error codes in use today are on that list, so here's Apache's list:
|
446
|
-
http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#apache-response-codes-57
|
447
|
-
|
448
|
-
400 Bad Request
|
449
|
-
* The request could not be understood by the server due to malformed syntax.
|
450
|
-
* The client SHOULD NOT repeat the request without modifications.
|
451
|
-
403 Forbidden
|
452
|
-
* The server understood the request, but is refusing to fulfill it
|
453
|
-
404 Not Found
|
454
|
-
* The server has not found anything matching the Request-URI
|
455
|
-
405 Method Not Allowed
|
456
|
-
* The method specified in the Request-Line is not allowed for the resource identified by the Request-URI
|
457
|
-
* This is not implemented entirely as the response is supposed to contain a list of accepted methods.
|
458
|
-
410 Gone
|
459
|
-
* The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent
|
460
|
-
418 I'm a teapot
|
461
|
-
* ErrorDocument I'm a teapot | Sample 418 I'm a teapot
|
462
|
-
* The HTCPCP server is a teapot. The responding entity MAY be short and stout. Defined by the April Fools specification RFC 2324. See Hyper Text Coffee Pot Control Protocol for more information.
|
463
|
-
422 Unprocessable Entity
|
464
|
-
* ErrorDocument Unprocessable Entity | Sample 422 Unprocessable Entity
|
465
|
-
* (WebDAV) (RFC 4918 ) - The request was well-formed but was unable to be followed due to semantic errors.
|
466
|
-
423 Locked
|
467
|
-
* ErrorDocument Locked | Sample 423 Locked
|
468
|
-
* (WebDAV) (RFC 4918 ) - The resource that is being accessed is locked
|
469
|
-
500 Internal Server Error
|
470
|
-
* The server encountered an unexpected condition which prevented it from fulfilling the request.
|
471
|
-
501 Not Implemented
|
472
|
-
* The server does not support the functionality required to fulfill the request.
|
473
|
-
503 Service Unavailable
|
474
|
-
* The server is currently unable to handle the request due to a temporary overloading or maintenance of the server.
|
475
|
-
|
476
|
-
== CSS
|
477
|
-
|
478
|
-
All the standard error pages that come in the gem render a div with a class of "dialog",
|
479
|
-
so put this in a stylesheet you are including in your app to get you started (like standard rails error style):
|
480
|
-
|
481
|
-
<style type="text/css">
|
482
|
-
div.dialog {
|
483
|
-
width: 25em;
|
484
|
-
padding: 0 4em;
|
485
|
-
margin: 4em auto 0 auto;
|
486
|
-
border: 1px solid #ccc;
|
487
|
-
border-right-color: #999;
|
488
|
-
border-bottom-color: #999;
|
489
|
-
}
|
490
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
491
|
-
</style>
|
492
|
-
|
493
|
-
== Authors
|
494
|
-
|
495
|
-
Jamis Buck and Peter Boling
|
496
|
-
|
497
|
-
== Contributors
|
498
|
-
|
499
|
-
I've merged many other people's forks into my fork. Thanks to all of you who contributed good ideas that I have ripped off!
|
500
|
-
|
501
|
-
If I fail to mention you below, please let me know.
|
502
|
-
|
503
|
-
jamescook, ismasan, sentientmonkey
|
504
|
-
|
505
|
-
== jamescook changes
|
506
|
-
|
507
|
-
Hooks into `git blame` output so you can get an idea of who (may) have introduced the bug :)
|
508
|
-
-- Usage: set ExceptionNotification::Notifier.config[:git_repo_path] to the path of your git repo.
|
509
|
-
|
510
|
-
== ismasan changes
|
511
|
-
|
512
|
-
POST exception data in JSON format to the specified services for processing
|
513
|
-
-- Usage:
|
514
|
-
ExceptionNotification::Notifier.configure_exception_notifier do |config|
|
515
|
-
config[:web_hooks] = %w(http://some-hook-service.example.com http://another-hook-service.example.com) # defaults to []
|
516
|
-
config[:app_name] = "[APP]" # defaults to [MYAPP]
|
517
|
-
config[:exception_recipients] = %w(my@example.com another@example.com) # defaults to []
|
518
|
-
config[:sender_address] = %("Application Error" <app.error@myapp.com>) # defaults to super.exception.notifier@example.com
|
519
|
-
end
|
520
|
-
|
521
|
-
== sentientmonkey changes
|
522
|
-
|
523
|
-
Now you can get notifications from rake tasks! Use 'NotifiedTask.new' instead of 'task':
|
524
|
-
-- Usage:
|
525
|
-
NotifiedTask.new :sometask => :environment do
|
526
|
-
puts "I'm a task"
|
527
|
-
end
|
528
|
-
|
529
|
-
== Bugs
|
530
|
-
|
531
|
-
# NOTE: Some people (myself included) experience a bug in rails versions > 2.3.3
|
532
|
-
# which forces us to use a simple email address string for the sender address.
|
533
|
-
# https://rails.lighthouseapp.com/projects/8994/tickets/2340
|
534
|
-
config[:sender_address] = "super.exception.notifier@example.com"
|
112
|
+
4. That’s it! The defaults take care of the rest.
|
535
113
|
|
536
|
-
|
114
|
+
http://wiki.github.com/pboling/exception_notification/exceptions-inside-request-cycle
|
537
115
|
|
538
|
-
|
539
|
-
http://super-exception-notifier.googlecode.com
|
116
|
+
== Advanced Configuration
|
540
117
|
|
541
|
-
|
118
|
+
There is a lot more you can configure, and do:
|
542
119
|
|
543
|
-
|
544
|
-
Portions Copyright (c) 2005 Jamis Buck, released under the MIT license
|
120
|
+
http://wiki.github.com/pboling/exception_notification/
|
data/VERSION.yml
CHANGED
@@ -53,6 +53,6 @@ module ExceptionNotification::DeprecatedMethods
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def deprecation_warning(old, new, reason = "")
|
56
|
-
|
56
|
+
logger.info("[DEPRECATION WARNING] ** Method '#{old}' has been replaced by '#{new}', please update your code.#{' Reason for change: ' + reason + '.' if reason}")
|
57
57
|
end
|
58
58
|
end
|
@@ -112,48 +112,47 @@ module ExceptionNotification::ExceptionNotifiable
|
|
112
112
|
|
113
113
|
#No Request present
|
114
114
|
# When the action being executed has its own local error handling (rescue)
|
115
|
-
# Or when the error
|
116
|
-
def
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
#to_return
|
115
|
+
# Or when the error occurs somewhere without a subsequent render (eg. method calls in console)
|
116
|
+
def rescue_with_handler(exception)
|
117
|
+
to_return = super
|
118
|
+
if to_return
|
119
|
+
verbose = self.class.exception_notifiable_verbose && respond_to?(:logger) && !logger.nil?
|
120
|
+
logger.info("[RESCUE STYLE] rescue_with_handler") if verbose
|
121
|
+
data = get_exception_data
|
122
|
+
status_code = status_code_for_exception(exception)
|
123
|
+
#We only send email if it has been configured in environment
|
124
|
+
send_email = should_email_on_exception?(exception, status_code, verbose)
|
125
|
+
#We only send web hooks if they've been configured in environment
|
126
|
+
send_web_hooks = should_web_hook_on_exception?(exception, status_code, verbose)
|
127
|
+
the_blamed = ExceptionNotification::Notifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)
|
128
|
+
rejected_sections = %w(request session)
|
129
|
+
# Debugging output
|
130
|
+
verbose_output(exception, status_code, "rescued by handler", send_email, send_web_hooks, nil, the_blamed, rejected_sections) if verbose
|
131
|
+
# Send the exception notification email
|
132
|
+
perform_exception_notify_mailing(exception, data, nil, the_blamed, verbose, rejected_sections) if send_email
|
133
|
+
# Send Web Hook requests
|
134
|
+
ExceptionNotification::HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotification::Notifier.config, exception, self, request, data, the_blamed) if send_web_hooks
|
135
|
+
pass_it_on(exception, ENV)
|
136
|
+
end
|
137
|
+
to_return
|
139
138
|
end
|
140
139
|
|
141
140
|
# Overrides the rescue_action method in ActionController::Base, but does not inhibit
|
142
141
|
# any custom processing that is defined with Rails 2's exception helpers.
|
143
142
|
# When the action being executed is letting SEN handle the exception completely
|
144
143
|
def rescue_action_in_public(exception)
|
145
|
-
# If the error class is NOT listed in the
|
144
|
+
# If the error class is NOT listed in the rails_error_class hash then we get a generic 500 error:
|
146
145
|
# OTW if the error class is listed, but has a blank code or the code is == '200' then we get a custom error layout rendered
|
147
146
|
# OTW the error class is listed!
|
148
|
-
verbose = self.class.exception_notifiable_verbose
|
149
|
-
|
147
|
+
verbose = self.class.exception_notifiable_verbose && respond_to?(:logger) && !logger.nil?
|
148
|
+
logger.info("[RESCUE STYLE] rescue_action_in_public") if verbose
|
150
149
|
status_code = status_code_for_exception(exception)
|
151
150
|
if status_code == '200'
|
152
151
|
notify_and_render_error_template(status_code, request, exception, ExceptionNotification::Notifier.get_view_path_for_class(exception, verbose), verbose)
|
153
152
|
else
|
154
153
|
notify_and_render_error_template(status_code, request, exception, ExceptionNotification::Notifier.get_view_path_for_status_code(status_code, verbose), verbose)
|
155
154
|
end
|
156
|
-
pass_it_on(exception, request)
|
155
|
+
pass_it_on(exception, ENV, request, params, session)
|
157
156
|
end
|
158
157
|
|
159
158
|
def notify_and_render_error_template(status_cd, request, exception, file_path, verbose = false)
|
@@ -183,19 +182,59 @@ module ExceptionNotification::ExceptionNotifiable
|
|
183
182
|
# some integration with hoptoad or other exception handler
|
184
183
|
# is done by tha alias method chain on:
|
185
184
|
# rescue_action_locally
|
186
|
-
def pass_it_on(exception, request =
|
185
|
+
def pass_it_on(exception, env, request = {:params => {}}, params = {}, session = {})
|
187
186
|
begin
|
188
|
-
request ||= {:params => {}}
|
189
187
|
case self.class.exception_notifiable_pass_through
|
190
188
|
when :hoptoad then
|
191
|
-
HoptoadNotifier.notify(exception,
|
192
|
-
|
189
|
+
HoptoadNotifier.notify(exception, sen_hoptoad_request_data(env, request, params, session))
|
190
|
+
logger.info("[PASS-IT-ON] HOPTOAD NOTIFIED") if verbose
|
193
191
|
else
|
194
|
-
|
195
|
-
#
|
192
|
+
logger.info("[PASS-IT-ON] NO") if verbose
|
193
|
+
#Do Nothing
|
196
194
|
end
|
197
195
|
rescue
|
198
|
-
#
|
196
|
+
#Do Nothing
|
197
|
+
logger.info("[PASS-IT-ON] FAILED") if verbose
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def sen_hoptoad_request_data(env, request, params, session)
|
202
|
+
{ :parameters => sen_hoptoad_filter_if_filtering(params.to_hash),
|
203
|
+
:session_data => sen_hoptoad_session_data(session),
|
204
|
+
:controller => params[:controller],
|
205
|
+
:action => params[:action],
|
206
|
+
:url => sen_hoptoad_request_url(request),
|
207
|
+
:cgi_data => request.respond_to?(:env) ? sen_hoptoad_filter_if_filtering(request.env) : nil,
|
208
|
+
:environment_vars => sen_hoptoad_filter_if_filtering(env),
|
209
|
+
:request => request }
|
210
|
+
end
|
211
|
+
|
212
|
+
def sen_hoptoad_filter_if_filtering(hash)
|
213
|
+
if respond_to?(:filter_parameters)
|
214
|
+
filter_parameters(hash) rescue hash
|
215
|
+
else
|
216
|
+
hash
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def sen_hoptoad_session_data(session)
|
221
|
+
if session.respond_to?(:to_hash)
|
222
|
+
session.to_hash
|
223
|
+
elsif session.respond_to?(:data)
|
224
|
+
session.data
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def sen_hoptoad_request_url(request)
|
229
|
+
if request.respond_to?(:protocol)
|
230
|
+
url = "#{request.protocol}#{request.host}"
|
231
|
+
|
232
|
+
unless [80, 443].include?(request.port)
|
233
|
+
url << ":#{request.port}"
|
234
|
+
end
|
235
|
+
|
236
|
+
url << request.request_uri
|
237
|
+
url
|
199
238
|
end
|
200
239
|
end
|
201
240
|
|
@@ -67,8 +67,8 @@ module ExceptionNotification::Notifiable
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def rescue_with_hooks(exception)
|
70
|
-
verbose = self.class.notifiable_verbose
|
71
|
-
|
70
|
+
verbose = self.class.notifiable_verbose && respond_to?(:logger) && !logger.nil?
|
71
|
+
logger.info("[RESCUE STYLE] rescue_with_hooks") if verbose
|
72
72
|
data = get_exception_data
|
73
73
|
# With ExceptionNotifiable you have an inherent request, and using a status code makes sense.
|
74
74
|
# With Notifiable class to wrap around everything that doesn't have a request,
|
@@ -98,13 +98,14 @@ module ExceptionNotification::Notifiable
|
|
98
98
|
case self.class.notifiable_pass_through
|
99
99
|
when :hoptoad then
|
100
100
|
HoptoadNotifier.notify(exception, {:request => request})
|
101
|
-
|
101
|
+
logger.info("[PASS-IT-ON] HOPTOAD NOTIFIED") if verbose
|
102
102
|
else
|
103
|
-
|
104
|
-
#
|
103
|
+
logger.info("[PASS-IT-ON] NO") if verbose
|
104
|
+
#Do Nothing
|
105
105
|
end
|
106
106
|
rescue
|
107
|
-
#
|
107
|
+
#Do Nothing
|
108
|
+
logger.info("[PASS-IT-ON] FAILED") if verbose
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
@@ -27,29 +27,29 @@ module ExceptionNotification::NotifiableHelper
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def verbose_output(exception, status_cd, file_path, send_email, send_web_hooks, request = nil, the_blamed = nil, rejected_sections = nil)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
req = request ? " for request_uri=#{request.request_uri}
|
41
|
-
logger.error("render_error(#{status_cd}, #{self.class.http_status_codes[status_cd]}) invoked#{req}") if self.class.respond_to?(:http_status_codes)
|
30
|
+
logger.info("[EXCEPTION] #{exception}")
|
31
|
+
logger.info("[EXCEPTION CLASS] #{exception.class}")
|
32
|
+
logger.info("[EXCEPTION STATUS_CD] #{status_cd}")
|
33
|
+
logger.info("[ERROR LAYOUT] #{self.class.error_layout}") if self.class.respond_to?(:error_layout)
|
34
|
+
logger.info("[ERROR VIEW PATH] #{ExceptionNotification::Notifier.config[:view_path]}") if !ExceptionNotification::Notifier.nil? && !ExceptionNotification::Notifier.config[:view_path].nil?
|
35
|
+
logger.info("[ERROR FILE PATH] #{file_path.inspect}")
|
36
|
+
logger.info("[ERROR EMAIL] #{send_email ? "YES" : "NO"}")
|
37
|
+
logger.info("[ERROR WEB HOOKS] #{send_web_hooks ? "YES" : "NO"}")
|
38
|
+
logger.info("[THE BLAMED] #{the_blamed}") unless the_blamed.blank?
|
39
|
+
logger.info("[SECTIONS] #{ExceptionNotification::Notifier.sections_for_email(rejected_sections, request).inspect}")
|
40
|
+
req = request ? " for request_uri=#{request.request_uri}" : ""
|
41
|
+
logger.error("render_error(#{status_cd}, #{self.class.http_status_codes[status_cd]}) invoked#{req}") if self.class.respond_to?(:http_status_codes)
|
42
42
|
end
|
43
43
|
|
44
44
|
def perform_exception_notify_mailing(exception, data, request = nil, the_blamed = nil, verbose = false, rejected_sections = nil)
|
45
45
|
if ExceptionNotification::Notifier.config[:exception_recipients].blank?
|
46
|
-
|
46
|
+
logger.info("[EMAIL NOTIFICATION] ExceptionNotification::Notifier.config[:exception_recipients] is blank, notification cancelled!") if verbose
|
47
47
|
else
|
48
48
|
class_name = self.respond_to?(:controller_name) ? self.controller_name : self.to_s
|
49
49
|
method_name = self.respond_to?(:action_name) ? self.action_name : get_method_name
|
50
50
|
ExceptionNotification::Notifier.deliver_exception_notification(exception, class_name, method_name,
|
51
51
|
request, data, the_blamed, rejected_sections)
|
52
|
-
|
52
|
+
logger.info("[EMAIL NOTIFICATION] Sent") if verbose
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -65,8 +65,8 @@ module ExceptionNotification::NotifiableHelper
|
|
65
65
|
def should_notify_on_exception?(exception, status_cd = nil, verbose = false)
|
66
66
|
# don't notify (email or web hooks) on exceptions raised locally
|
67
67
|
verbose && ExceptionNotification::Notifier.config[:skip_local_notification] && is_local? ?
|
68
|
-
|
69
|
-
|
68
|
+
logger.info("[NOTIFY LOCALLY] NO") :
|
69
|
+
nil
|
70
70
|
return false if ExceptionNotification::Notifier.config[:skip_local_notification] && is_local?
|
71
71
|
# don't notify (email or web hooks) exceptions raised that match ExceptionNotifiable.notifiable_silent_exceptions
|
72
72
|
return false if self.be_silent_for_exception?(exception)
|
@@ -87,26 +87,26 @@ class ExceptionNotification::Notifier < ActionMailer::Base
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def self.catch_all(verbose = false)
|
90
|
-
|
90
|
+
logger.info("[CATCH ALL INVOKED] #{File.dirname(__FILE__)}/../../rails/app/views/exception_notifiable/500.html") if verbose
|
91
91
|
"#{File.dirname(__FILE__)}/../../rails/app/views/exception_notifiable/500.html"
|
92
92
|
end
|
93
93
|
|
94
94
|
# Check the usual suspects
|
95
95
|
def self.get_view_path(file_name, verbose = false)
|
96
96
|
if File.exist?("#{RAILS_ROOT}/public/#{file_name}.html")
|
97
|
-
|
97
|
+
logger.info("[FOUND FILE:A] #{RAILS_ROOT}/public/#{file_name}.html") if verbose
|
98
98
|
"#{RAILS_ROOT}/public/#{file_name}.html"
|
99
99
|
elsif !config[:view_path].nil? && File.exist?("#{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html.erb")
|
100
|
-
|
100
|
+
logger.info("[FOUND FILE:B] #{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html.erb") if verbose
|
101
101
|
"#{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html.erb"
|
102
102
|
elsif !config[:view_path].nil? && File.exist?("#{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html")
|
103
|
-
|
103
|
+
logger.info("[FOUND FILE:C] #{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html") if verbose
|
104
104
|
"#{RAILS_ROOT}/#{config[:view_path]}/#{file_name}.html"
|
105
105
|
elsif File.exist?("#{File.dirname(__FILE__)}/../../rails/app/views/exception_notifiable/#{file_name}.html.erb")
|
106
|
-
|
106
|
+
logger.info("[FOUND FILE:D] #{File.dirname(__FILE__)}/../../rails/app/views/exception_notifiable/#{file_name}.html.erb") if verbose
|
107
107
|
"#{File.dirname(__FILE__)}/../../rails/app/views/exception_notifiable/#{file_name}.html.erb"
|
108
108
|
elsif File.exist?("#{File.dirname(__FILE__)}/../../rails/app/views/exception_notifiable/#{file_name}.html")
|
109
|
-
|
109
|
+
logger.info("[FOUND FILE:E] #{File.dirname(__FILE__)}/../../rails/app/views/exception_notifiable/#{file_name}.html") if verbose
|
110
110
|
"#{File.dirname(__FILE__)}/../../rails/app/views/exception_notifiable/#{file_name}.html"
|
111
111
|
else
|
112
112
|
nil
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @backtrace.join "\n" %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% if @request -%>
|
2
|
+
<% max = @request.env.keys.max { |a,b| a.length <=> b.length } -%>
|
3
|
+
<% @request.env.keys.sort.each do |key| -%>
|
4
|
+
* <%= "%-*s: %s" % [max.length, key, filter_sensitive_post_data_from_env(key, @request.env[key].to_s.strip)] %>
|
5
|
+
<% end -%>
|
6
|
+
<% end -%>
|
7
|
+
<% if @data -%>
|
8
|
+
<% @data.each do |key, value| -%>
|
9
|
+
* <%= key %>: <%= value %>
|
10
|
+
<% end -%>
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
* Process: <%= $$ %>
|
14
|
+
* Server : <%= `hostname -s`.chomp %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% if show_attributes -%>
|
2
|
+
[attributes]
|
3
|
+
<% attrs = inspect_model.attributes -%>
|
4
|
+
<% max = attrs.keys.max { |a,b| a.length <=> b.length } -%>
|
5
|
+
<% attrs.keys.sort.each do |attr| -%>
|
6
|
+
* <%= "%*-s: %s" % [max.length, attr, object_to_yaml(attrs[attr]).gsub(/\n/, "\n ").strip] %>
|
7
|
+
<% end -%>
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
<% if show_instance_variables -%>
|
11
|
+
[instance variables]
|
12
|
+
<% inspect_model.instance_variables.sort.each do |variable| -%>
|
13
|
+
<%- next if variable == "@attributes" -%>
|
14
|
+
* <%= variable %>: <%= inspect_value(inspect_model.instance_variable_get(variable)) %>
|
15
|
+
<% end -%>
|
16
|
+
<% end -%>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% if @request -%>
|
2
|
+
* URL : <%= @request.protocol %><%= @host %><%= @request.request_uri %>
|
3
|
+
* Method : <%= @request.method.to_s.upcase %>
|
4
|
+
* IP address: <%= @request.env['HTTP_X_REAL_IP'] ||@request.env["HTTP_X_FORWARDED_FOR"] || @request.env["REMOTE_ADDR"] %>
|
5
|
+
* Parameters: <%= filter_sensitive_post_data_parameters(@request.parameters).inspect %>
|
6
|
+
<% end -%>
|
7
|
+
* Rails root: <%= @rails_root %>
|
8
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%
|
2
|
+
@request.session.instance_variable_set(:@session_id, @request.session_options[:id]) if @request.session.instance_variable_get(:@session_id).nil?
|
3
|
+
@request.session.instance_variable_set(:@data, @request.session.to_hash) if @request.session.instance_variable_get(:@data).nil?
|
4
|
+
%>
|
5
|
+
* session id: <%= @request.session.instance_variable_get(:@session_id).inspect %>
|
6
|
+
* data: <%= PP.pp(@request.session.instance_variable_get(:@data),"").gsub(/\n/, "\n ").strip %>
|
data/lib/views/exception_notification/notifier/background_exception_notification.text.plain.erb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
A <%= @exception.class %> occurred in <%= @controller_name %>#<%= @controller_action_name %>:
|
2
|
+
|
3
|
+
<%= @exception.message %>
|
4
|
+
<%= @backtrace.first %>
|
5
|
+
|
6
|
+
<% if @data[:info] -%>
|
7
|
+
<%=@data[:info].to_yaml%>
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
<%= @sections.map { |section| render_section(section) }.join %>
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{super_exception_notifier}
|
8
|
-
s.version = "3.0.
|
8
|
+
s.version = "3.0.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Peter Boling", "Scott Windsor", "Ismael Celis", "Jacques Crocker", "Jamis Buck"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-06-12}
|
13
13
|
s.description = %q{Allows customization of:
|
14
14
|
* Specify which level of notification you would like with an array of optional styles of notification (email, webhooks)
|
15
15
|
* the sender address of the email
|
@@ -34,7 +34,8 @@ Gem::Specification.new do |s|
|
|
34
34
|
"README"
|
35
35
|
]
|
36
36
|
s.files = [
|
37
|
-
"
|
37
|
+
"CHANGELOG.txt",
|
38
|
+
"MIT-LICENSE",
|
38
39
|
"README",
|
39
40
|
"VERSION.yml",
|
40
41
|
"init.rb",
|
@@ -52,6 +53,14 @@ Gem::Specification.new do |s|
|
|
52
53
|
"lib/exception_notification/notified_task.rb",
|
53
54
|
"lib/exception_notification/notifier.rb",
|
54
55
|
"lib/exception_notification/notifier_helper.rb",
|
56
|
+
"lib/views/exception_notification/notifier/_backtrace.html.erb",
|
57
|
+
"lib/views/exception_notification/notifier/_environment.html.erb",
|
58
|
+
"lib/views/exception_notification/notifier/_inspect_model.html.erb",
|
59
|
+
"lib/views/exception_notification/notifier/_request.html.erb",
|
60
|
+
"lib/views/exception_notification/notifier/_session.html.erb",
|
61
|
+
"lib/views/exception_notification/notifier/_title.html.erb",
|
62
|
+
"lib/views/exception_notification/notifier/background_exception_notification.text.plain.erb",
|
63
|
+
"lib/views/exception_notification/notifier/rake_exception_notification.text.plain.erb",
|
55
64
|
"rails/app/views/exception_notifiable/400.html",
|
56
65
|
"rails/app/views/exception_notifiable/403.html",
|
57
66
|
"rails/app/views/exception_notifiable/404.html",
|
@@ -70,7 +79,7 @@ Gem::Specification.new do |s|
|
|
70
79
|
s.homepage = %q{http://github.com/pboling/exception_notifiable}
|
71
80
|
s.rdoc_options = ["--charset=UTF-8"]
|
72
81
|
s.require_paths = ["lib"]
|
73
|
-
s.rubygems_version = %q{1.3.
|
82
|
+
s.rubygems_version = %q{1.3.7}
|
74
83
|
s.summary = %q{Allows unhandled (and handled!) exceptions to be captured and sent via email}
|
75
84
|
s.test_files = [
|
76
85
|
"test/exception_notifiable_test.rb",
|
@@ -86,7 +95,7 @@ Gem::Specification.new do |s|
|
|
86
95
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
87
96
|
s.specification_version = 3
|
88
97
|
|
89
|
-
if Gem::Version.new(Gem::
|
98
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
90
99
|
s.add_runtime_dependency(%q<actionmailer>, [">= 0"])
|
91
100
|
s.add_runtime_dependency(%q<rake>, [">= 0"])
|
92
101
|
else
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_exception_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 3
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 3.0.
|
9
|
+
- 7
|
10
|
+
version: 3.0.7
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Peter Boling
|
@@ -18,16 +19,18 @@ autorequire:
|
|
18
19
|
bindir: bin
|
19
20
|
cert_chain: []
|
20
21
|
|
21
|
-
date: 2010-
|
22
|
+
date: 2010-06-12 00:00:00 -04:00
|
22
23
|
default_executable:
|
23
24
|
dependencies:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: actionmailer
|
26
27
|
prerelease: false
|
27
28
|
requirement: &id001 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
28
30
|
requirements:
|
29
31
|
- - ">="
|
30
32
|
- !ruby/object:Gem::Version
|
33
|
+
hash: 3
|
31
34
|
segments:
|
32
35
|
- 0
|
33
36
|
version: "0"
|
@@ -37,9 +40,11 @@ dependencies:
|
|
37
40
|
name: rake
|
38
41
|
prerelease: false
|
39
42
|
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
40
44
|
requirements:
|
41
45
|
- - ">="
|
42
46
|
- !ruby/object:Gem::Version
|
47
|
+
hash: 3
|
43
48
|
segments:
|
44
49
|
- 0
|
45
50
|
version: "0"
|
@@ -73,6 +78,7 @@ extensions: []
|
|
73
78
|
extra_rdoc_files:
|
74
79
|
- README
|
75
80
|
files:
|
81
|
+
- CHANGELOG.txt
|
76
82
|
- MIT-LICENSE
|
77
83
|
- README
|
78
84
|
- VERSION.yml
|
@@ -91,6 +97,14 @@ files:
|
|
91
97
|
- lib/exception_notification/notified_task.rb
|
92
98
|
- lib/exception_notification/notifier.rb
|
93
99
|
- lib/exception_notification/notifier_helper.rb
|
100
|
+
- lib/views/exception_notification/notifier/_backtrace.html.erb
|
101
|
+
- lib/views/exception_notification/notifier/_environment.html.erb
|
102
|
+
- lib/views/exception_notification/notifier/_inspect_model.html.erb
|
103
|
+
- lib/views/exception_notification/notifier/_request.html.erb
|
104
|
+
- lib/views/exception_notification/notifier/_session.html.erb
|
105
|
+
- lib/views/exception_notification/notifier/_title.html.erb
|
106
|
+
- lib/views/exception_notification/notifier/background_exception_notification.text.plain.erb
|
107
|
+
- lib/views/exception_notification/notifier/rake_exception_notification.text.plain.erb
|
94
108
|
- rails/app/views/exception_notifiable/400.html
|
95
109
|
- rails/app/views/exception_notifiable/403.html
|
96
110
|
- rails/app/views/exception_notifiable/404.html
|
@@ -105,6 +119,13 @@ files:
|
|
105
119
|
- rails/app/views/exception_notifiable/method_disabled.html.erb
|
106
120
|
- rails/init.rb
|
107
121
|
- super_exception_notifier.gemspec
|
122
|
+
- test/exception_notifiable_test.rb
|
123
|
+
- test/exception_notifier_helper_test.rb
|
124
|
+
- test/exception_notifier_test.rb
|
125
|
+
- test/exception_notify_functional_test.rb
|
126
|
+
- test/mocks/controllers.rb
|
127
|
+
- test/notifiable_test.rb
|
128
|
+
- test/test_helper.rb
|
108
129
|
has_rdoc: true
|
109
130
|
homepage: http://github.com/pboling/exception_notifiable
|
110
131
|
licenses: []
|
@@ -115,23 +136,27 @@ rdoc_options:
|
|
115
136
|
require_paths:
|
116
137
|
- lib
|
117
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
118
140
|
requirements:
|
119
141
|
- - ">="
|
120
142
|
- !ruby/object:Gem::Version
|
143
|
+
hash: 3
|
121
144
|
segments:
|
122
145
|
- 0
|
123
146
|
version: "0"
|
124
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
125
149
|
requirements:
|
126
150
|
- - ">="
|
127
151
|
- !ruby/object:Gem::Version
|
152
|
+
hash: 3
|
128
153
|
segments:
|
129
154
|
- 0
|
130
155
|
version: "0"
|
131
156
|
requirements: []
|
132
157
|
|
133
158
|
rubyforge_project:
|
134
|
-
rubygems_version: 1.3.
|
159
|
+
rubygems_version: 1.3.7
|
135
160
|
signing_key:
|
136
161
|
specification_version: 3
|
137
162
|
summary: Allows unhandled (and handled!) exceptions to be captured and sent via email
|