super_exception_notifier 2.0.1 → 2.0.2
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/VERSION.yml
CHANGED
data/lib/exception_notifiable.rb
CHANGED
@@ -102,9 +102,11 @@ module ExceptionNotifiable
|
|
102
102
|
#We only send web hooks if they've been configured in environment
|
103
103
|
send_web_hooks = should_web_hook_on_exception?(exception, status_code, verbose)
|
104
104
|
the_blamed = ExceptionNotifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)
|
105
|
-
|
106
|
-
#
|
107
|
-
|
105
|
+
rejected_sections = %w(request session)
|
106
|
+
# Debugging output
|
107
|
+
verbose_output(exception, status_code, "rescued by handler", send_email, send_web_hooks, nil, the_blamed, rejected_sections) if verbose
|
108
|
+
# Send the exception notification email
|
109
|
+
perform_exception_notify_mailing(exception, data, nil, the_blamed, verbose, rejected_sections) if send_email
|
108
110
|
# Send Web Hook requests
|
109
111
|
HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotifier.config, exception, self, request, data, the_blamed) if send_web_hooks
|
110
112
|
end
|
@@ -134,13 +136,13 @@ module ExceptionNotifiable
|
|
134
136
|
#We only send web hooks if they've been configured in environment
|
135
137
|
send_web_hooks = should_web_hook_on_exception?(exception, status_cd, verbose)
|
136
138
|
the_blamed = ExceptionNotifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)
|
137
|
-
|
139
|
+
rejected_sections = request.nil? ? %w(request session) : []
|
138
140
|
# Debugging output
|
139
|
-
verbose_output(exception, status_cd, file_path, send_email, send_web_hooks, request, the_blamed) if verbose
|
140
|
-
|
141
|
+
verbose_output(exception, status_cd, file_path, send_email, send_web_hooks, request, the_blamed, rejected_sections) if verbose
|
141
142
|
#TODO: is _rescue_action something from rails 3?
|
142
143
|
#if !(self.controller_name == 'application' && self.action_name == '_rescue_action')
|
143
|
-
|
144
|
+
# Send the exception notification email
|
145
|
+
perform_exception_notify_mailing(exception, data, request, the_blamed, verbose, rejected_sections) if send_email
|
144
146
|
# Send Web Hook requests
|
145
147
|
HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotifier.config, exception, self, request, data, the_blamed) if send_web_hooks
|
146
148
|
|
data/lib/exception_notifier.rb
CHANGED
@@ -53,6 +53,11 @@ class ExceptionNotifier < ActionMailer::Base
|
|
53
53
|
filenames
|
54
54
|
end
|
55
55
|
|
56
|
+
def self.sections_for_email(rejected_sections, request)
|
57
|
+
rejected_sections = rejected_sections.nil? ? request.nil? ? %w(request session) : [] : rejected_sections
|
58
|
+
rejected_sections.empty? ? config[:sections] : config[:sections].reject{|s| rejected_sections.include?(s) }
|
59
|
+
end
|
60
|
+
|
56
61
|
# Converts Stringified Class Names to acceptable filename handles with underscores
|
57
62
|
def self.filenamify(str)
|
58
63
|
str.delete(':').gsub( /([A-Za-z])([A-Z])/, '\1' << '_' << '\2').downcase
|
@@ -110,8 +115,8 @@ class ExceptionNotifier < ActionMailer::Base
|
|
110
115
|
end
|
111
116
|
end
|
112
117
|
|
113
|
-
def exception_notification(exception, class_name = nil, method_name = nil, request = nil, data={}, the_blamed=nil)
|
114
|
-
body_hash = error_environment_data_hash(exception, class_name, method_name, request, data, the_blamed)
|
118
|
+
def exception_notification(exception, class_name = nil, method_name = nil, request = nil, data = {}, the_blamed = nil, rejected_sections = nil)
|
119
|
+
body_hash = error_environment_data_hash(exception, class_name, method_name, request, data, the_blamed, rejected_sections)
|
115
120
|
#Prefer to have custom, potentially HTML email templates available
|
116
121
|
#content_type "text/plain"
|
117
122
|
recipients config[:exception_recipients]
|
@@ -123,30 +128,17 @@ class ExceptionNotifier < ActionMailer::Base
|
|
123
128
|
body body_hash
|
124
129
|
end
|
125
130
|
|
126
|
-
def background_exception_notification(exception, data = {}, the_blamed = nil)
|
127
|
-
exception_notification(exception, nil, nil, data, the_blamed)
|
131
|
+
def background_exception_notification(exception, data = {}, the_blamed = nil, rejected_sections = %w(request session))
|
132
|
+
exception_notification(exception, nil, nil, nil, data, the_blamed, rejected_sections)
|
128
133
|
end
|
129
134
|
|
130
|
-
def rake_exception_notification(exception, task, data={})
|
131
|
-
|
132
|
-
|
133
|
-
subject "#{email_prefix}#{task.name} (#{exception.class}) #{exception.message.inspect}"
|
134
|
-
|
135
|
-
recipients exception_recipients
|
136
|
-
from sender_address
|
137
|
-
|
138
|
-
body data.merge({ :task => task,
|
139
|
-
:exception => exception,
|
140
|
-
:backtrace => sanitize_backtrace(exception.backtrace),
|
141
|
-
:rails_root => rails_root,
|
142
|
-
:data => data,
|
143
|
-
:sections => sections.reject{|s| %w(request session).include?(s) }
|
144
|
-
})
|
135
|
+
def rake_exception_notification(exception, task, data={}, the_blamed = nil, rejected_sections = %w(request session))
|
136
|
+
exception_notification(exception, "", "#{task.name}", nil, data, the_blamed, rejected_sections)
|
145
137
|
end
|
146
138
|
|
147
139
|
private
|
148
140
|
|
149
|
-
def error_environment_data_hash(exception, class_name = nil, method_name = nil, request = nil, data={}, the_blamed=nil)
|
141
|
+
def error_environment_data_hash(exception, class_name = nil, method_name = nil, request = nil, data = {}, the_blamed = nil, rejected_sections = nil)
|
150
142
|
data.merge!({
|
151
143
|
:exception => exception,
|
152
144
|
:backtrace => sanitize_backtrace(exception.backtrace),
|
@@ -159,17 +151,16 @@ class ExceptionNotifier < ActionMailer::Base
|
|
159
151
|
data.merge!({:method_name => method_name}) if method_name
|
160
152
|
if class_name && method_name
|
161
153
|
data.merge!({:location => "#{class_name}##{method_name}"})
|
154
|
+
elsif method_name
|
155
|
+
data.merge!({:location => "#{method_name}"})
|
162
156
|
else
|
163
157
|
data.merge!({:location => sanitize_backtrace([exception.backtrace.first]).first})
|
164
158
|
end
|
165
159
|
if request
|
166
160
|
data.merge!({:request => request})
|
167
161
|
data.merge!({:host => (request.env['HTTP_X_REAL_IP'] || request.env["HTTP_X_FORWARDED_HOST"] || request.env["HTTP_HOST"])})
|
168
|
-
data.merge!({:sections => config[:sections]})
|
169
|
-
else
|
170
|
-
# TODO: with refactoring in the view structure, the environment section could show useful ENV data even without a request?
|
171
|
-
data.merge!({:sections => config[:sections] - %w(request session environment)})
|
172
162
|
end
|
163
|
+
data.merge!({:sections => ExceptionNotifier.sections_for_email(rejected_sections, request)})
|
173
164
|
return data
|
174
165
|
end
|
175
166
|
|
data/lib/notifiable.rb
CHANGED
@@ -76,9 +76,10 @@ module Notifiable
|
|
76
76
|
#We only send web hooks if they've been configured in environment
|
77
77
|
send_web_hooks = should_web_hook_on_exception?(exception, status_code, verbose)
|
78
78
|
the_blamed = ExceptionNotifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
rejected_sections = %w(request session)
|
80
|
+
verbose_output(exception, status_code, "rescued by handler", send_email, send_web_hooks, nil, the_blamed, rejected_sections) if verbose
|
81
|
+
# Send the exception notification email
|
82
|
+
perform_exception_notify_mailing(exception, data, nil, the_blamed, verbose, rejected_sections) if send_email
|
82
83
|
# Send Web Hook requests
|
83
84
|
HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotifier.config, exception, self, request, data, the_blamed) if send_web_hooks
|
84
85
|
end
|
@@ -27,7 +27,7 @@ module SuperExceptionNotifier
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def verbose_output(exception, status_cd, file_path, send_email, send_web_hooks, request = nil, the_blamed = nil)
|
30
|
+
def verbose_output(exception, status_cd, file_path, send_email, send_web_hooks, request = nil, the_blamed = nil, rejected_sections = nil)
|
31
31
|
puts "[EXCEPTION] #{exception}"
|
32
32
|
puts "[EXCEPTION CLASS] #{exception.class}"
|
33
33
|
puts "[EXCEPTION STATUS_CD] #{status_cd}"
|
@@ -38,18 +38,19 @@ module SuperExceptionNotifier
|
|
38
38
|
puts "[ERROR WEB HOOKS] #{send_web_hooks ? "YES" : "NO"}"
|
39
39
|
puts "[COMPAT MODE] #{ExceptionNotifierHelper::COMPAT_MODE ? "YES" : "NO"}"
|
40
40
|
puts "[THE BLAMED] #{the_blamed}"
|
41
|
+
puts "[SECTIONS] #{ExceptionNotifier.sections_for_email(rejected_sections, request)}"
|
41
42
|
req = request ? " for request_uri=#{request.request_uri} and env=#{request.env.inspect}" : ""
|
42
43
|
logger.error("render_error(#{status_cd}, #{self.class.http_status_codes[status_cd]}) invoked#{req}") if self.class.respond_to?(:http_status_codes) && !logger.nil?
|
43
44
|
end
|
44
45
|
|
45
|
-
def perform_exception_notify_mailing(exception, data, request = nil, the_blamed = nil, verbose = false)
|
46
|
+
def perform_exception_notify_mailing(exception, data, request = nil, the_blamed = nil, verbose = false, rejected_sections = nil)
|
46
47
|
if ExceptionNotifier.config[:exception_recipients].blank?
|
47
48
|
puts "[EMAIL NOTIFICATION] ExceptionNotifier.config[:exception_recipients] is blank, notification cancelled!" if verbose
|
48
49
|
else
|
49
50
|
class_name = self.respond_to?(:controller_name) ? self.controller_name : self.to_s
|
50
51
|
method_name = self.respond_to?(:action_name) ? self.action_name : get_method_name
|
51
52
|
ExceptionNotifier.deliver_exception_notification(exception, class_name, method_name,
|
52
|
-
request, data, the_blamed)
|
53
|
+
request, data, the_blamed, rejected_sections)
|
53
54
|
puts "[EMAIL NOTIFICATION] Sent" if verbose
|
54
55
|
end
|
55
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_exception_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2009-10-
|
16
|
+
date: 2009-10-23 00:00:00 -04:00
|
17
17
|
default_executable:
|
18
18
|
dependencies: []
|
19
19
|
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- views/exception_notifier/_title.html.erb
|
82
82
|
- views/exception_notifier/background_exception_notification.text.plain.erb
|
83
83
|
- views/exception_notifier/exception_notification.text.plain.erb
|
84
|
+
- views/exception_notifier/rake_exception_notification.text.plain.erb
|
84
85
|
has_rdoc: true
|
85
86
|
homepage: http://github.com/pboling/exception_notification
|
86
87
|
licenses: []
|