super_exception_notifier 3.0.5 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 5
2
+ :patch: 6
3
3
  :major: 3
4
4
  :build:
5
5
  :minor: 0
@@ -12,4 +12,23 @@ module ExceptionNotification
12
12
  autoload :DeprecatedMethods, 'exception_notification/deprecated_methods'
13
13
  autoload :HooksNotifier, 'exception_notification/hooks_notifier'
14
14
  autoload :NotifiableHelper, 'exception_notification/notifiable_helper'
15
+
16
+ def self.initialize
17
+ if defined?(ActionController::Base)
18
+ ActionController::Base.send(:include, ExceptionNotification::ExceptionNotifiable)
19
+ end
20
+
21
+ #TODO: Set this in gobal SEN config as the logger like they do in HoptoadNotifier
22
+ # rails_logger = if defined?(::Rails.logger)
23
+ # ::Rails.logger
24
+ # elsif defined?(RAILS_DEFAULT_LOGGER)
25
+ # RAILS_DEFAULT_LOGGER
26
+ # end
27
+ # HoptoadNotifier.configure(true) do |config|
28
+ # config.logger = rails_logger
29
+ # config.environment_name = RAILS_ENV if defined?(RAILS_ENV)
30
+ # config.project_root = RAILS_ROOT if defined?(RAILS_ROOT)
31
+ # config.framework = "Rails: #{::Rails::VERSION::STRING}" if defined?(::Rails::VERSION)
32
+ # end
33
+ end
15
34
  end
@@ -1,3 +1,5 @@
1
+ # This module needs to be included in ApplicationController in order to work.
2
+
1
3
  require 'ipaddr'
2
4
 
3
5
  module ExceptionNotification::ExceptionNotifiable
@@ -6,6 +8,17 @@ module ExceptionNotification::ExceptionNotifiable
6
8
  def self.included(base)
7
9
  base.extend ClassMethods
8
10
 
11
+ # Sets up an alias chain to catch exceptions when Rails does
12
+ #This is what makes it all work with Hoptoad or other exception catchers.
13
+ # base.send(:alias_method, :rescue_action_locally_without_sen_handler, :rescue_action_locally)
14
+ # base.send(:alias_method, :rescue_action_locally, :rescue_action_locally_with_sen_handler)
15
+
16
+ #Alias method chaining doesn't work here because it would trigger a double render error.
17
+ # Sets up an alias chain to catch exceptions when Rails does
18
+ #This is what makes it all work with Hoptoad or other exception catchers.
19
+ # base.send(:alias_method, :rescue_action_in_public_without_exception_notifiable, :rescue_action_in_public)
20
+ # base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_exception_notifiable)
21
+
9
22
  # Adds the following class attributes to the classes that include ExceptionNotifiable
10
23
  # HTTP status codes and what their 'English' status message is
11
24
  base.cattr_accessor :http_status_codes
@@ -72,7 +85,6 @@ module ExceptionNotification::ExceptionNotifiable
72
85
  self.class.be_silent_for_exception?(exception)
73
86
  end
74
87
 
75
-
76
88
  private
77
89
 
78
90
  def environment_is_noisy?
@@ -98,32 +110,36 @@ module ExceptionNotification::ExceptionNotifiable
98
110
  !self.class.local_addresses.detect { |addr| addr.include?(remote) }.nil?
99
111
  end
100
112
 
113
+ #No Request present
101
114
  # When the action being executed has its own local error handling (rescue)
102
115
  # Or when the error accurs somewhere without a subsequent render (eg. method calls in console)
103
- def rescue_with_handler(exception)
104
- to_return = super
105
- if to_return
106
- verbose = self.class.exception_notifiable_verbose
107
- puts "[RESCUE STYLE] rescue_with_handler" if verbose
108
- data = get_exception_data
109
- status_code = status_code_for_exception(exception)
110
- #We only send email if it has been configured in environment
111
- send_email = should_email_on_exception?(exception, status_code, verbose)
112
- #We only send web hooks if they've been configured in environment
113
- send_web_hooks = should_web_hook_on_exception?(exception, status_code, verbose)
114
- the_blamed = ExceptionNotification::Notifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)
115
- rejected_sections = %w(request session)
116
- # Debugging output
117
- verbose_output(exception, status_code, "rescued by handler", send_email, send_web_hooks, nil, the_blamed, rejected_sections) if verbose
118
- # Send the exception notification email
119
- perform_exception_notify_mailing(exception, data, nil, the_blamed, verbose, rejected_sections) if send_email
120
- # Send Web Hook requests
121
- ExceptionNotification::HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotification::Notifier.config, exception, self, request, data, the_blamed) if send_web_hooks
122
- end
116
+ def rescue_action_locally_with_sen_handler(exception)
117
+ #to_return = super
118
+ #if to_return
119
+ verbose = self.class.exception_notifiable_verbose
120
+ puts "[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
+ #end
123
136
  pass_it_on(exception)
124
- to_return
137
+ #rescue_action_locally_without_sen_handler(exception)
138
+ #to_return
125
139
  end
126
140
 
141
+ # Overrides the rescue_action method in ActionController::Base, but does not inhibit
142
+ # any custom processing that is defined with Rails 2's exception helpers.
127
143
  # When the action being executed is letting SEN handle the exception completely
128
144
  def rescue_action_in_public(exception)
129
145
  # If the error class is NOT listed in the rails_errror_class hash then we get a generic 500 error:
@@ -137,6 +153,7 @@ module ExceptionNotification::ExceptionNotifiable
137
153
  else
138
154
  notify_and_render_error_template(status_code, request, exception, ExceptionNotification::Notifier.get_view_path_for_status_code(status_code, verbose), verbose)
139
155
  end
156
+ pass_it_on(exception, request)
140
157
  end
141
158
 
142
159
  def notify_and_render_error_template(status_cd, request, exception, file_path, verbose = false)
@@ -161,15 +178,17 @@ module ExceptionNotification::ExceptionNotifiable
161
178
  # deliver raises an exception, we don't call render twice.
162
179
  # Render the error page to the end user
163
180
  render_error_template(file_path, status)
164
- pass_it_on(exception, request)
165
181
  end
166
182
 
183
+ # some integration with hoptoad or other exception handler
184
+ # is done by tha alias method chain on:
185
+ # rescue_action_locally
167
186
  def pass_it_on(exception, request = nil)
168
187
  begin
169
188
  request ||= {:params => {}}
170
189
  case self.class.exception_notifiable_pass_through
171
190
  when :hoptoad then
172
- HoptoadNotifier.notify_or_ignore(exception, {:request => request})
191
+ HoptoadNotifier.notify(exception, {:request => request})
173
192
  puts "[PASS-IT-ON] HOPTOAD NOTIFIED" if verbose
174
193
  else
175
194
  puts "[PASS-IT-ON] NO" if verbose
@@ -97,7 +97,7 @@ module ExceptionNotification::Notifiable
97
97
  request ||= {:params => {}}
98
98
  case self.class.notifiable_pass_through
99
99
  when :hoptoad then
100
- HoptoadNotifier.notify_or_ignore(exception, {:request => request})
100
+ HoptoadNotifier.notify(exception, {:request => request})
101
101
  puts "[PASS-IT-ON] HOPTOAD NOTIFIED" if verbose
102
102
  else
103
103
  puts "[PASS-IT-ON] NO" if verbose
@@ -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.5"
8
+ s.version = "3.0.6"
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-05-13}
12
+ s.date = %q{2010-05-14}
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 3
7
7
  - 0
8
- - 5
9
- version: 3.0.5
8
+ - 6
9
+ version: 3.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Peter Boling
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-05-13 00:00:00 -04:00
21
+ date: 2010-05-14 00:00:00 -04:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency