pboling-super_exception_notifier 1.6.8 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -56,7 +56,7 @@ Gem Using Git building from source:
56
56
  git clone git://github.com/pboling/exception_notification.git
57
57
  cd exception_notification
58
58
  gem build exception_notification.gemspec
59
- sudo gem install super_exception_notification-1.6.8.gem # (Or whatever version gets built)
59
+ sudo gem install super_exception_notification-1.7.0.gem # (Or whatever version gets built)
60
60
 
61
61
  Then cd to your rails app to optionally freeze the gem into your app:
62
62
 
@@ -65,7 +65,7 @@ Then cd to your rails app to optionally freeze the gem into your app:
65
65
  Then in your environment.rb:
66
66
 
67
67
  config.gem 'super_exception_notifier',
68
- :version => '~> 1.6.8',
68
+ :version => '~> 1.7.0',
69
69
  :lib => "exception_notifier"
70
70
 
71
71
 
@@ -77,7 +77,7 @@ Installing Gem from Github's Gem Server:
77
77
  Then in your environment.rb:
78
78
 
79
79
  config.gem 'pboling-super_exception_notifier',
80
- :version => '~> 1.6.9',
80
+ :version => '~> 1.7.0',
81
81
  :lib => "exception_notifier",
82
82
  :source => 'http://gems.github.com'
83
83
 
@@ -170,12 +170,14 @@ The availalbe configuration options are shown with their default settings:
170
170
  "501" => "Not Implemented",
171
171
  "503" => "Service Unavailable"
172
172
  }
173
+
173
174
  # error_layout:
174
175
  # can be defined at controller level to the name of the desired error layout,
175
176
  # or set to true to render the controller's own default layout,
176
177
  # or set to false to render errors with no layout
177
178
  # syntax is the same as the rails 'layout' method (which is to say a string)
178
179
  self.error_layout = nil
180
+
179
181
  # Rails error classes to rescue and how to rescue them (which error code to use)
180
182
  self.rails_error_classes = {
181
183
  # These are standard errors in rails / ruby
@@ -192,6 +194,7 @@ The availalbe configuration options are shown with their default settings:
192
194
  NotImplemented => "501",
193
195
  MethodDisabled => "200"
194
196
  }
197
+
195
198
  # Highly dependent on the verison of rails, so we're very protective about these'
196
199
  self.rails_error_classes.merge!({ ActionView::TemplateError => "500"}) if defined?(ActionView) && ActionView.const_defined?(:TemplateError)
197
200
  self.rails_error_classes.merge!({ ActiveRecord::RecordNotFound => "400" }) if defined?(ActiveRecord) && ActiveRecord.const_defined?(:RecordNotFound)
@@ -205,17 +208,20 @@ The availalbe configuration options are shown with their default settings:
205
208
  self.rails_error_classes.merge!({ ActionController::RoutingError => "404" }) if ActionController.const_defined?(:RoutingError)
206
209
  self.rails_error_classes.merge!({ ActionController::InvalidAuthenticityToken => "405" }) if ActionController.const_defined?(:InvalidAuthenticityToken)
207
210
  end
211
+
208
212
  # Verbosity of the gem (true or false) mainly useful for debugging
209
213
  self.exception_notifier_verbose = false
214
+
210
215
  # Do Not Ever send error notification emails for these Error Classes
211
216
  self.silent_exceptions = []
212
217
  self.silent_exceptions << ActiveRecord::RecordNotFound if defined?(ActiveRecord)
213
- self.silent_exceptions << [
214
- ActionController::UnknownController,
215
- ActionController::UnknownAction,
216
- ActionController::RoutingError,
217
- ActionController::MethodNotAllowed
218
- ] if defined?(ActionController)
218
+ if defined?(ActionController)
219
+ self.silent_exceptions << ActionController::UnknownController
220
+ self.silent_exceptions << ActionController::UnknownAction
221
+ self.silent_exceptions << ActionController::RoutingError
222
+ self.silent_exceptions << ActionController::MethodNotAllowed
223
+ end
224
+
219
225
  # Notification Level
220
226
  # Web Hooks, even though they are turned on by default, only get used if you actually configure them in the environment (see above)
221
227
  # Email, even though it is turned on by default, only gets used if you actually configure recipients in the environment (see above)
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 6
4
- :patch: 8
3
+ :minor: 7
4
+ :patch: 0
@@ -1,17 +1,18 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'super_exception_notifier'
3
- s.version = '1.6.8'
4
- s.date = '2009-08-15'
3
+ s.version = '1.7.0'
4
+ s.date = '2009-08-16'
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
 
7
7
  s.summary = %q{Allows unhandled (and handled!) exceptions to be captured and sent via email}
8
8
  s.description = %q{Allows customization of:
9
+ * Specify which level of notification you would like with an array of optional styles of notification (email, webhooks)
9
10
  * the sender address of the email
10
11
  * the recipient addresses
11
12
  * the text used to prefix the subject line
12
- * the HTTP status codes to send emails for
13
+ * the HTTP status codes to notify for
13
14
  * the error classes to send emails for
14
- * alternatively, the error classes to not send emails for
15
+ * alternatively, the error classes to not notify for
15
16
  * whether to send error emails or just render without sending anything
16
17
  * the HTTP status and status code that gets rendered with specific errors
17
18
  * the view path to the error page templates
@@ -21,7 +22,7 @@ Gem::Specification.new do |s|
21
22
  * Override the gem's handling and rendering with explicit rescue statements inline.
22
23
  * Hooks into `git blame` output so you can get an idea of who (may) have introduced the bug
23
24
  * Hooks into other website services (e.g. you can send exceptions to to Switchub.com)
24
- * Specify which level of notification you would like with an array of optional styles of notification}
25
+ }
25
26
 
26
27
  s.authors = ['Peter Boling', 'Jacques Crocker', 'Jamis Buck']
27
28
  s.email = 'peter.boling@gmail.com'
@@ -6,14 +6,15 @@ module ExceptionNotifiable
6
6
  include HooksNotifier
7
7
 
8
8
  unless defined?(SILENT_EXCEPTIONS)
9
- SILENT_EXCEPTIONS = []
10
- SILENT_EXCEPTIONS << ActiveRecord::RecordNotFound if defined?(ActiveRecord)
11
- SILENT_EXCEPTIONS << [
12
- ActionController::UnknownController,
13
- ActionController::UnknownAction,
14
- ActionController::RoutingError,
15
- ActionController::MethodNotAllowed
16
- ] if defined?(ActionController)
9
+ noiseless = []
10
+ noiseless << ActiveRecord::RecordNotFound if defined?(ActiveRecord)
11
+ if defined?(ActionController)
12
+ noiseless << ActionController::UnknownController
13
+ noiseless << ActionController::UnknownAction
14
+ noiseless << ActionController::RoutingError
15
+ noiseless << ActionController::MethodNotAllowed
16
+ end
17
+ SILENT_EXCEPTIONS = noiseless
17
18
  end
18
19
 
19
20
  # TODO: use ActionController::StatusCodes
@@ -230,26 +231,21 @@ module ExceptionNotifiable
230
231
  end
231
232
 
232
233
  def should_email_on_exception?(exception, status_cd = nil, verbose = false)
233
- notification_level_sends_email? && !ExceptionNotifier.config[:exception_recipients].empty? && should_notify_on_exception?(exception, status_cd)
234
+ notification_level_sends_email? && !ExceptionNotifier.config[:exception_recipients].empty? && should_notify_on_exception?(exception, status_cd, verbose)
234
235
  end
235
236
 
236
237
  def should_web_hook_on_exception?(exception, status_cd = nil, verbose = false)
237
- notification_level_sends_web_hooks? && !ExceptionNotifier.config[:web_hooks].empty? && should_notify_on_exception?(exception, status_cd)
238
+ notification_level_sends_web_hooks? && !ExceptionNotifier.config[:web_hooks].empty? && should_notify_on_exception?(exception, status_cd, verbose)
238
239
  end
239
240
 
240
241
  def should_notify_on_exception?(exception, status_cd = nil, verbose = false)
241
- puts "checking if should notify on exception E:#{exception} C: #{exception} SC: #{status_cd}" if verbose
242
242
  # don't notify (email or web hooks) on exceptions raised locally
243
243
  puts "skipping local notification" if verbose && ExceptionNotifier.config[:skip_local_notification] && is_local?
244
244
  return false if ExceptionNotifier.config[:skip_local_notification] && is_local?
245
245
  # don't notify (email or web hooks) exceptions raised that match ExceptionNotifiable.silent_exceptions
246
- puts "skipping silent exception notification: K:#{klass} E:#{exception} C:#{exception.class}" if verbose && self.class.silent_exceptions.any? {|klass| klass === exception }
247
- return false if self.class.silent_exceptions.any? {|klass| klass === exception }
248
- puts "notifying for: E:#{exception} C:#{exception.class}" if verbose && ExceptionNotifier.config[:notify_error_classes].include?(exception)
249
- return true if ExceptionNotifier.config[:notify_error_classes].include?(exception)
250
- puts "notifying for status code: #{status_cd}" if verbose && !status_cd.nil? && ExceptionNotifier.config[:notify_error_codes].include?(status_cd)
246
+ return false if self.class.silent_exceptions.respond_to?(:any?) && self.class.silent_exceptions.any? {|klass| klass === exception }
247
+ return true if ExceptionNotifier.config[:notify_error_classes].include?(exception.class)
251
248
  return true if !status_cd.nil? && ExceptionNotifier.config[:notify_error_codes].include?(status_cd)
252
- puts "Notify [#{ExceptionNotifier.config[:notify_other_errors] ? "YES" : "NO"}] Other Error: status code: #{status_cd} E:#{exception} C:#{exception.class}" if verbose
253
249
  return ExceptionNotifier.config[:notify_other_errors]
254
250
  end
255
251
 
@@ -91,7 +91,31 @@ class ExceptionNotifyFunctionalTest < ActionController::TestCase
91
91
  get "record_not_found"
92
92
  assert_nothing_mailed
93
93
  end
94
-
94
+
95
+ def test_controller_with_custom_silent_exceptions
96
+ @controller = CustomSilentExceptions.new
97
+ get "runtime_error"
98
+ assert_nothing_mailed
99
+ end
100
+
101
+ def test_controller_with_empty_silent_exceptions
102
+ @controller = EmptySilentExceptions.new
103
+ get "record_not_found"
104
+ assert_error_mail_contains("ActiveRecord::RecordNotFound")
105
+ end
106
+
107
+ def test_controller_with_nil_silent_exceptions
108
+ @controller = NilSilentExceptions.new
109
+ get "record_not_found"
110
+ assert_error_mail_contains("ActiveRecord::RecordNotFound")
111
+ end
112
+
113
+ def test_controller_with_default_silent_exceptions
114
+ @controller = DefaultSilentExceptions.new
115
+ get "unknown_controller"
116
+ assert_nothing_mailed
117
+ end
118
+
95
119
  private
96
120
 
97
121
  def assert_view_path_for_status_cd_is_string(status)
@@ -104,7 +128,7 @@ class ExceptionNotifyFunctionalTest < ActionController::TestCase
104
128
 
105
129
  def assert_error_mail_contains(text)
106
130
  assert(mailed_error.index(text),
107
- "Expected mailed error body to contain '#{text}', but not found. \n actual contents: \n#{mailed_error}")
131
+ "Expected mailed error body to contain '#{text}', but not found. \n actual contents: \n#{mailed_error}")
108
132
  end
109
133
 
110
134
  def assert_nothing_mailed
@@ -13,23 +13,51 @@ class Application < ActionController::Base
13
13
  def runtime_error
14
14
  raise "This is a runtime error that we should be emailed about"
15
15
  end
16
-
16
+
17
17
  def record_not_found
18
18
  raise ActiveRecord::RecordNotFound
19
19
  end
20
-
20
+
21
+ def unknown_controller
22
+ raise ActionController::UnknownController
23
+ end
24
+
21
25
  def local_request?
22
26
  false
23
27
  end
24
28
 
25
29
  end
26
30
 
27
- class OldStyle < Application
31
+ class SpecialErrorThing < RuntimeError
32
+ end
33
+
34
+ class CustomSilentExceptions < Application
28
35
  include ExceptionNotifiable
29
36
  self.exception_notifier_verbose = false
37
+ self.silent_exceptions = [RuntimeError]
30
38
  end
31
39
 
32
- class SpecialErrorThing < RuntimeError
40
+ class EmptySilentExceptions < Application
41
+ include ExceptionNotifiable
42
+ self.exception_notifier_verbose = false
43
+ self.silent_exceptions = []
44
+ end
45
+
46
+ class NilSilentExceptions < Application
47
+ include ExceptionNotifiable
48
+ self.exception_notifier_verbose = false
49
+ self.silent_exceptions = nil
50
+ end
51
+
52
+ class DefaultSilentExceptions < Application
53
+ include ExceptionNotifiable
54
+ self.exception_notifier_verbose = false
55
+ puts self.silent_exceptions.inspect
56
+ end
57
+
58
+ class OldStyle < Application
59
+ include ExceptionNotifiable
60
+ self.exception_notifier_verbose = false
33
61
  end
34
62
 
35
63
  class NewStyle < Application
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pboling-super_exception_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.8
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-08-15 00:00:00 -07:00
14
+ date: 2009-08-16 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  - !ruby/object:Gem::Version
25
25
  version: "2.1"
26
26
  version:
27
- description: "Allows customization of: * the sender address of the email * the recipient addresses * the text used to prefix the subject line * the HTTP status codes to send emails for * the error classes to send emails for * alternatively, the error classes to not send emails for * whether to send error emails or just render without sending anything * the HTTP status and status code that gets rendered with specific errors * the view path to the error page templates * custom errors, with custom error templates * define error layouts at application or controller level, or use the controller's own default layout, or no layout at all * get error notification for errors that occur in the console, using notifiable method * Override the gem's handling and rendering with explicit rescue statements inline. * Hooks into `git blame` output so you can get an idea of who (may) have introduced the bug * Hooks into other website services (e.g. you can send exceptions to to Switchub.com) * Specify which level of notification you would like with an array of optional styles of notification"
27
+ description: "Allows customization of: * Specify which level of notification you would like with an array of optional styles of notification (email, webhooks) * the sender address of the email * the recipient addresses * the text used to prefix the subject line * the HTTP status codes to notify for * the error classes to send emails for * alternatively, the error classes to not notify for * whether to send error emails or just render without sending anything * the HTTP status and status code that gets rendered with specific errors * the view path to the error page templates * custom errors, with custom error templates * define error layouts at application or controller level, or use the controller's own default layout, or no layout at all * get error notification for errors that occur in the console, using notifiable method * Override the gem's handling and rendering with explicit rescue statements inline. * Hooks into `git blame` output so you can get an idea of who (may) have introduced the bug * Hooks into other website services (e.g. you can send exceptions to to Switchub.com)"
28
28
  email: peter.boling@gmail.com
29
29
  executables: []
30
30