exception_notification 3.0.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Appraisals +7 -0
- data/CHANGELOG.rdoc +129 -1
- data/CODE_OF_CONDUCT.md +22 -0
- data/CONTRIBUTING.md +29 -1
- data/Gemfile +1 -1
- data/MIT-LICENSE +23 -0
- data/README.md +168 -222
- data/Rakefile +5 -11
- data/docs/notifiers/campfire.md +50 -0
- data/docs/notifiers/custom.md +42 -0
- data/docs/notifiers/datadog.md +51 -0
- data/docs/notifiers/email.md +195 -0
- data/docs/notifiers/google_chat.md +31 -0
- data/docs/notifiers/hipchat.md +66 -0
- data/docs/notifiers/irc.md +97 -0
- data/docs/notifiers/mattermost.md +115 -0
- data/docs/notifiers/slack.md +161 -0
- data/docs/notifiers/sns.md +37 -0
- data/docs/notifiers/teams.md +54 -0
- data/docs/notifiers/webhook.md +60 -0
- data/examples/sample_app.rb +54 -0
- data/examples/sinatra/Gemfile +8 -0
- data/examples/sinatra/Gemfile.lock +95 -0
- data/examples/sinatra/Procfile +2 -0
- data/examples/sinatra/README.md +11 -0
- data/examples/sinatra/config.ru +3 -0
- data/examples/sinatra/sinatra_app.rb +36 -0
- data/exception_notification.gemspec +32 -11
- data/gemfiles/rails4_0.gemfile +7 -0
- data/gemfiles/rails4_1.gemfile +7 -0
- data/gemfiles/rails4_2.gemfile +7 -0
- data/gemfiles/rails5_0.gemfile +7 -0
- data/gemfiles/rails5_1.gemfile +7 -0
- data/gemfiles/rails5_2.gemfile +7 -0
- data/gemfiles/rails6_0.gemfile +7 -0
- data/lib/exception_notification.rb +11 -0
- data/lib/exception_notification/rack.rb +55 -0
- data/lib/exception_notification/rails.rb +9 -0
- data/lib/exception_notification/resque.rb +22 -0
- data/lib/exception_notification/sidekiq.rb +27 -0
- data/lib/exception_notification/version.rb +3 -0
- data/lib/exception_notifier.rb +137 -61
- data/lib/exception_notifier/base_notifier.rb +24 -0
- data/lib/exception_notifier/campfire_notifier.rb +16 -11
- data/lib/exception_notifier/datadog_notifier.rb +153 -0
- data/lib/exception_notifier/email_notifier.rb +196 -0
- data/lib/exception_notifier/google_chat_notifier.rb +42 -0
- data/lib/exception_notifier/hipchat_notifier.rb +49 -0
- data/lib/exception_notifier/irc_notifier.rb +57 -0
- data/lib/exception_notifier/mattermost_notifier.rb +72 -0
- data/lib/exception_notifier/modules/backtrace_cleaner.rb +11 -0
- data/lib/exception_notifier/modules/error_grouping.rb +77 -0
- data/lib/exception_notifier/modules/formatter.rb +118 -0
- data/lib/exception_notifier/notifier.rb +9 -179
- data/lib/exception_notifier/slack_notifier.rb +111 -0
- data/lib/exception_notifier/sns_notifier.rb +85 -0
- data/lib/exception_notifier/teams_notifier.rb +193 -0
- data/lib/exception_notifier/views/exception_notifier/_backtrace.html.erb +3 -1
- data/lib/exception_notifier/views/exception_notifier/_data.html.erb +6 -1
- data/lib/exception_notifier/views/exception_notifier/_environment.html.erb +8 -6
- data/lib/exception_notifier/views/exception_notifier/_environment.text.erb +1 -4
- data/lib/exception_notifier/views/exception_notifier/_request.html.erb +36 -5
- data/lib/exception_notifier/views/exception_notifier/_request.text.erb +10 -5
- data/lib/exception_notifier/views/exception_notifier/_session.html.erb +10 -2
- data/lib/exception_notifier/views/exception_notifier/_session.text.erb +2 -2
- data/lib/exception_notifier/views/exception_notifier/_title.html.erb +3 -3
- data/lib/exception_notifier/views/exception_notifier/background_exception_notification.html.erb +38 -11
- data/lib/exception_notifier/views/exception_notifier/background_exception_notification.text.erb +10 -11
- data/lib/exception_notifier/views/exception_notifier/exception_notification.html.erb +38 -22
- data/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb +2 -3
- data/lib/exception_notifier/webhook_notifier.rb +51 -0
- data/lib/generators/exception_notification/install_generator.rb +15 -0
- data/lib/generators/exception_notification/templates/exception_notification.rb.erb +55 -0
- data/test/exception_notification/rack_test.rb +60 -0
- data/test/exception_notification/resque_test.rb +52 -0
- data/test/exception_notifier/campfire_notifier_test.rb +120 -0
- data/test/exception_notifier/datadog_notifier_test.rb +151 -0
- data/test/exception_notifier/email_notifier_test.rb +351 -0
- data/test/exception_notifier/google_chat_notifier_test.rb +181 -0
- data/test/exception_notifier/hipchat_notifier_test.rb +218 -0
- data/test/exception_notifier/irc_notifier_test.rb +137 -0
- data/test/exception_notifier/mattermost_notifier_test.rb +202 -0
- data/test/exception_notifier/modules/error_grouping_test.rb +165 -0
- data/test/exception_notifier/modules/formatter_test.rb +150 -0
- data/test/exception_notifier/sidekiq_test.rb +38 -0
- data/test/exception_notifier/slack_notifier_test.rb +227 -0
- data/test/exception_notifier/sns_notifier_test.rb +121 -0
- data/test/exception_notifier/teams_notifier_test.rb +90 -0
- data/test/exception_notifier/webhook_notifier_test.rb +96 -0
- data/test/exception_notifier_test.rb +182 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.html.erb +0 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.text.erb +0 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_section.html.erb +0 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_section.text.erb +0 -0
- data/test/test_helper.rb +12 -8
- metadata +333 -164
- data/.gemtest +0 -0
- data/Gemfile.lock +0 -122
- data/test/background_exception_notification_test.rb +0 -82
- data/test/campfire_test.rb +0 -53
- data/test/dummy/.gitignore +0 -4
- data/test/dummy/Gemfile +0 -33
- data/test/dummy/Gemfile.lock +0 -118
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/controllers/posts_controller.rb +0 -30
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/posts_helper.rb +0 -2
- data/test/dummy/app/models/post.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/posts/_form.html.erb +0 -0
- data/test/dummy/app/views/posts/new.html.erb +0 -0
- data/test/dummy/app/views/posts/show.html.erb +0 -0
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -42
- data/test/dummy/config/boot.rb +0 -6
- data/test/dummy/config/database.yml +0 -22
- data/test/dummy/config/environment.rb +0 -13
- data/test/dummy/config/environments/development.rb +0 -24
- data/test/dummy/config/environments/production.rb +0 -49
- data/test/dummy/config/environments/test.rb +0 -35
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -3
- data/test/dummy/db/migrate/20110729022608_create_posts.rb +0 -15
- data/test/dummy/db/schema.rb +0 -24
- data/test/dummy/db/seeds.rb +0 -7
- data/test/dummy/lib/tasks/.gitkeep +0 -0
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -26
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/images/rails.png +0 -0
- data/test/dummy/public/index.html +0 -239
- data/test/dummy/public/javascripts/application.js +0 -2
- data/test/dummy/public/javascripts/controls.js +0 -965
- data/test/dummy/public/javascripts/dragdrop.js +0 -974
- data/test/dummy/public/javascripts/effects.js +0 -1123
- data/test/dummy/public/javascripts/prototype.js +0 -6001
- data/test/dummy/public/javascripts/rails.js +0 -191
- data/test/dummy/public/robots.txt +0 -5
- data/test/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/dummy/public/stylesheets/scaffold.css +0 -56
- data/test/dummy/script/rails +0 -6
- data/test/dummy/test/fixtures/posts.yml +0 -11
- data/test/dummy/test/functional/posts_controller_test.rb +0 -239
- data/test/dummy/test/test_helper.rb +0 -13
- data/test/exception_notification_test.rb +0 -73
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'action_dispatch'
|
2
|
+
require 'active_support/core_ext/time'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module ExceptionNotifier
|
6
|
+
class TeamsNotifier < BaseNotifier
|
7
|
+
include ExceptionNotifier::BacktraceCleaner
|
8
|
+
|
9
|
+
class MissingController
|
10
|
+
def method_missing(*args, &block); end
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_accessor :httparty
|
14
|
+
|
15
|
+
def initialize(options = {})
|
16
|
+
super
|
17
|
+
@default_options = options
|
18
|
+
@httparty = HTTParty
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(exception, options = {})
|
22
|
+
@options = options.merge(@default_options)
|
23
|
+
@exception = exception
|
24
|
+
@backtrace = exception.backtrace ? clean_backtrace(exception) : nil
|
25
|
+
|
26
|
+
@env = @options.delete(:env)
|
27
|
+
|
28
|
+
@application_name = @options.delete(:app_name) || rails_app_name
|
29
|
+
@gitlab_url = @options.delete(:git_url)
|
30
|
+
@jira_url = @options.delete(:jira_url)
|
31
|
+
|
32
|
+
@webhook_url = @options.delete(:webhook_url)
|
33
|
+
raise ArgumentError, "You must provide 'webhook_url' parameter." unless @webhook_url
|
34
|
+
|
35
|
+
if @env.nil?
|
36
|
+
@controller = @request_items = nil
|
37
|
+
else
|
38
|
+
@controller = @env['action_controller.instance'] || MissingController.new
|
39
|
+
|
40
|
+
request = ActionDispatch::Request.new(@env)
|
41
|
+
|
42
|
+
@request_items = { url: request.original_url,
|
43
|
+
http_method: request.method,
|
44
|
+
ip_address: request.remote_ip,
|
45
|
+
parameters: request.filtered_parameters,
|
46
|
+
timestamp: Time.current }
|
47
|
+
|
48
|
+
if request.session['warden.user.user.key']
|
49
|
+
current_user = User.find(request.session['warden.user.user.key'][0][0])
|
50
|
+
@request_items[:current_user] = { id: current_user.id, email: current_user.email }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
payload = message_text
|
55
|
+
|
56
|
+
@options[:body] = payload.to_json
|
57
|
+
@options[:headers] ||= {}
|
58
|
+
@options[:headers]['Content-Type'] = 'application/json'
|
59
|
+
@options[:debug_output] = $stdout
|
60
|
+
|
61
|
+
@httparty.post(@webhook_url, @options)
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def message_text
|
67
|
+
errors_count = @options[:accumulated_errors_count].to_i
|
68
|
+
|
69
|
+
text = {
|
70
|
+
'@type' => 'MessageCard',
|
71
|
+
'@context' => 'http://schema.org/extensions',
|
72
|
+
'summary' => "#{@application_name} Exception Alert",
|
73
|
+
'title' => "⚠️ Exception Occurred in #{env_name} ⚠️",
|
74
|
+
'sections' => [
|
75
|
+
{
|
76
|
+
'activityTitle' => "#{errors_count > 1 ? errors_count : 'A'} *#{@exception.class}* occurred" + (@controller ? " in *#{controller_and_method}*." : '.'),
|
77
|
+
'activitySubtitle' => @exception.message.to_s
|
78
|
+
}
|
79
|
+
],
|
80
|
+
'potentialAction' => []
|
81
|
+
}
|
82
|
+
|
83
|
+
text['sections'].push details
|
84
|
+
text['potentialAction'].push gitlab_view_link unless @gitlab_url.nil?
|
85
|
+
text['potentialAction'].push gitlab_issue_link unless @gitlab_url.nil?
|
86
|
+
text['potentialAction'].push jira_issue_link unless @jira_url.nil?
|
87
|
+
|
88
|
+
text
|
89
|
+
end
|
90
|
+
|
91
|
+
def details
|
92
|
+
details = {
|
93
|
+
'title' => 'Details',
|
94
|
+
'facts' => []
|
95
|
+
}
|
96
|
+
|
97
|
+
details['facts'].push message_request unless @request_items.nil?
|
98
|
+
details['facts'].push message_backtrace unless @backtrace.nil?
|
99
|
+
|
100
|
+
details
|
101
|
+
end
|
102
|
+
|
103
|
+
def message_request
|
104
|
+
{
|
105
|
+
'name' => 'Request',
|
106
|
+
'value' => "#{hash_presentation(@request_items)}\n "
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
def message_backtrace(size = 3)
|
111
|
+
text = []
|
112
|
+
size = @backtrace.size < size ? @backtrace.size : size
|
113
|
+
text << '```'
|
114
|
+
size.times { |i| text << '* ' + @backtrace[i] }
|
115
|
+
text << '```'
|
116
|
+
|
117
|
+
{
|
118
|
+
'name' => 'Backtrace',
|
119
|
+
'value' => text.join(" \n").to_s
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def gitlab_view_link
|
124
|
+
{
|
125
|
+
'@type' => 'ViewAction',
|
126
|
+
'name' => "\u{1F98A} View in GitLab",
|
127
|
+
'target' => [
|
128
|
+
"#{@gitlab_url}/#{@application_name}"
|
129
|
+
]
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
def gitlab_issue_link
|
134
|
+
link = [@gitlab_url, @application_name, 'issues', 'new'].join('/')
|
135
|
+
params = {
|
136
|
+
'issue[title]' => ['[BUG] Error 500 :',
|
137
|
+
controller_and_method,
|
138
|
+
"(#{@exception.class})",
|
139
|
+
@exception.message].compact.join(' ')
|
140
|
+
}.to_query
|
141
|
+
|
142
|
+
{
|
143
|
+
'@type' => 'ViewAction',
|
144
|
+
'name' => "\u{1F98A} Create Issue in GitLab",
|
145
|
+
'target' => [
|
146
|
+
"#{link}/?#{params}"
|
147
|
+
]
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
def jira_issue_link
|
152
|
+
{
|
153
|
+
'@type' => 'ViewAction',
|
154
|
+
'name' => '🐞 Create Issue in Jira',
|
155
|
+
'target' => [
|
156
|
+
"#{@jira_url}/secure/CreateIssue!default.jspa"
|
157
|
+
]
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
161
|
+
def controller_and_method
|
162
|
+
if @controller
|
163
|
+
"#{@controller.controller_name}##{@controller.action_name}"
|
164
|
+
else
|
165
|
+
''
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def hash_presentation(hash)
|
170
|
+
text = []
|
171
|
+
|
172
|
+
hash.each do |key, value|
|
173
|
+
text << "* **#{key}** : `#{value}`"
|
174
|
+
end
|
175
|
+
|
176
|
+
text.join(" \n")
|
177
|
+
end
|
178
|
+
|
179
|
+
def rails_app_name
|
180
|
+
return unless defined?(Rails) && Rails.respond_to?(:application)
|
181
|
+
|
182
|
+
if ::Gem::Version.new(Rails.version) >= ::Gem::Version.new('6.0')
|
183
|
+
Rails.application.class.module_parent_name.underscore
|
184
|
+
else
|
185
|
+
Rails.application.class.parent_name.underscore
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def env_name
|
190
|
+
Rails.env if defined?(Rails) && Rails.respond_to?(:env)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
<% filtered_env = @request.filtered_env -%>
|
2
|
-
<% max = filtered_env.keys.map(&:to_s).max { |a, b| a.length <=> b.length } -%>
|
3
|
-
<% filtered_env.keys.map(&:to_s).sort.each do |key| -%>
|
4
|
-
* <%= raw("%-*s: %s" % [max.length, key, inspect_object(filtered_env[key])]) %>
|
5
|
-
<% end -%>
|
6
2
|
|
7
|
-
|
8
|
-
|
3
|
+
<ul style="list-style: none">
|
4
|
+
<% filtered_env.keys.map(&:to_s).sort.each do |key| -%>
|
5
|
+
<li>
|
6
|
+
<strong><%= key %>:</strong>
|
7
|
+
<span><%= inspect_object(filtered_env[key]) %></span>
|
8
|
+
</li>
|
9
|
+
<% end -%>
|
10
|
+
</ul>
|
@@ -1,8 +1,5 @@
|
|
1
1
|
<% filtered_env = @request.filtered_env -%>
|
2
2
|
<% max = filtered_env.keys.map(&:to_s).max { |a, b| a.length <=> b.length } -%>
|
3
3
|
<% filtered_env.keys.map(&:to_s).sort.each do |key| -%>
|
4
|
-
* <%= raw("%-*s: %s" % [max.length, key, inspect_object(filtered_env[key])]) %>
|
4
|
+
* <%= raw safe_encode("%-*s: %s" % [max.length, key, inspect_object(filtered_env[key])]).strip %>
|
5
5
|
<% end -%>
|
6
|
-
|
7
|
-
* Process: <%= raw $$ %>
|
8
|
-
* Server : <%= raw `hostname`.chomp %>
|
@@ -1,5 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<ul style="list-style: none">
|
2
|
+
<li>
|
3
|
+
<strong>URL:</strong>
|
4
|
+
<span><%= @request.url %></span>
|
5
|
+
</li>
|
6
|
+
<li>
|
7
|
+
<strong>HTTP Method:</strong>
|
8
|
+
<span><%= @request.request_method %></span>
|
9
|
+
</li>
|
10
|
+
<li>
|
11
|
+
<strong>IP Address:</strong>
|
12
|
+
<span><%= @request.remote_ip %></span>
|
13
|
+
</li>
|
14
|
+
<li>
|
15
|
+
<strong>Parameters:</strong>
|
16
|
+
<span><%= @request.filtered_parameters.inspect %></span>
|
17
|
+
</li>
|
18
|
+
<li>
|
19
|
+
<strong>Timestamp:</strong>
|
20
|
+
<span><%= @timestamp %></span>
|
21
|
+
</li>
|
22
|
+
<li>
|
23
|
+
<strong>Server:</strong>
|
24
|
+
<span><%= Socket.gethostname %></span>
|
25
|
+
</li>
|
26
|
+
<% if defined?(Rails) && Rails.respond_to?(:root) %>
|
27
|
+
<li>
|
28
|
+
<strong>Rails root:</strong>
|
29
|
+
<span><%= Rails.root %></span>
|
30
|
+
</li>
|
31
|
+
<% end %>
|
32
|
+
<li>
|
33
|
+
<strong>Process:</strong>
|
34
|
+
<span><%= $$ %></span>
|
35
|
+
</li>
|
36
|
+
</ul>
|
@@ -1,5 +1,10 @@
|
|
1
|
-
* URL
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
* Timestamp
|
1
|
+
* URL : <%= raw safe_encode @request.url %>
|
2
|
+
* HTTP Method: <%= raw @request.request_method %>
|
3
|
+
* IP address : <%= raw @request.remote_ip %>
|
4
|
+
* Parameters : <%= raw safe_encode @request.filtered_parameters.inspect %>
|
5
|
+
* Timestamp : <%= raw @timestamp %>
|
6
|
+
* Server : <%= raw Socket.gethostname %>
|
7
|
+
<% if defined?(Rails) && Rails.respond_to?(:root) %>
|
8
|
+
* Rails root : <%= raw Rails.root %>
|
9
|
+
<% end %>
|
10
|
+
* Process: <%= raw $$ %>
|
@@ -1,2 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<ul style="list-style: none">
|
2
|
+
<li>
|
3
|
+
<strong>session_id: </strong>
|
4
|
+
<span><%= @request.ssl? ? "[FILTERED]" : (@request.session['session_id'] || (@request.env["rack.session.options"] and @request.env["rack.session.options"][:id]).inspect) %></span>
|
5
|
+
</li>
|
6
|
+
<li>
|
7
|
+
<strong>data: </strong>
|
8
|
+
<span><%= PP.pp(@request.session.to_hash, "") %></span>
|
9
|
+
</li>
|
10
|
+
</ul>
|
@@ -1,2 +1,2 @@
|
|
1
|
-
* session id: <%= @request.ssl? ? "[FILTERED]" : (raw (@request.session['session_id'] || @request.env["rack.session.options"][:id]).inspect.html_safe) %>
|
2
|
-
* data: <%= raw PP.pp(@request.session, "") %>
|
1
|
+
* session id: <%= @request.ssl? ? "[FILTERED]" : (raw (@request.session['session_id'] || (@request.env["rack.session.options"] and @request.env["rack.session.options"][:id])).inspect.html_safe) %>
|
2
|
+
* data: <%= raw PP.pp(@request.session.to_hash, "") %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
<%=
|
3
|
-
|
1
|
+
<h2>
|
2
|
+
<%= title.to_s.humanize %>
|
3
|
+
</h2>
|
data/lib/exception_notifier/views/exception_notifier/background_exception_notification.html.erb
CHANGED
@@ -5,22 +5,49 @@
|
|
5
5
|
<title>Exception</title>
|
6
6
|
</head>
|
7
7
|
<body>
|
8
|
-
<pre style="font-size: 12px">
|
9
|
-
<%= @exception.class.to_s =~ /^[aeiou]/i ? 'An' : 'A' %> <%= @exception.class %> occurred in background at <%= raw Time.current %> :
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
sections = @sections.map do |section|
|
9
|
+
<%
|
10
|
+
sections_content = @sections.map do |section|
|
11
|
+
begin
|
15
12
|
summary = render(section).strip
|
16
13
|
unless summary.blank?
|
17
14
|
title = render("title", :title => section).strip
|
18
|
-
|
15
|
+
[title, summary]
|
19
16
|
end
|
20
|
-
|
21
|
-
|
17
|
+
|
18
|
+
rescue Exception => e
|
19
|
+
title = render("title", :title => section).strip
|
20
|
+
summary = ["ERROR: Failed to generate exception summary:", [e.class.to_s, e.message].join(": "), e.backtrace && e.backtrace.join("\n")].compact.join("\n\n")
|
21
|
+
|
22
|
+
[title, summary]
|
23
|
+
end
|
24
|
+
end
|
22
25
|
%>
|
23
|
-
|
24
|
-
|
26
|
+
|
27
|
+
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
28
|
+
<tr><td align="center" valign="top">
|
29
|
+
<table width="650" border="0" cellpadding="0" cellspacing="20">
|
30
|
+
<tr>
|
31
|
+
<td style="padding: 10px; border: 1px solid #eed3d7; background-color: #f2dede">
|
32
|
+
<h3 style="color: #b94a48">
|
33
|
+
<%= @exception.class.to_s =~ /^[aeiou]/i ? 'An' : 'A' %> <%= @exception.class %> occurred in background at <%= @timestamp %> :
|
34
|
+
</h3>
|
35
|
+
<p style="color: #b94a48"><%= @exception.message %></p>
|
36
|
+
<pre style="font-size: 12px; padding: 5px; background-color:#f5f5f5">
|
37
|
+
<%= @backtrace.first %>
|
38
|
+
</pre>
|
39
|
+
</td>
|
40
|
+
</tr>
|
41
|
+
<% sections_content.each do |title, summary| %>
|
42
|
+
<tr>
|
43
|
+
<td style="border-bottom: 1px solid #eeeeee;"><%= raw title %></td>
|
44
|
+
</tr>
|
45
|
+
<tr>
|
46
|
+
<td><%= raw summary %></td>
|
47
|
+
</tr>
|
48
|
+
<% end %>
|
49
|
+
</table>
|
50
|
+
</td></tr>
|
51
|
+
</table>
|
25
52
|
</body>
|
26
53
|
</html>
|
data/lib/exception_notifier/views/exception_notifier/background_exception_notification.text.erb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
<%= @exception.class.to_s =~ /^[aeiou]/i ? 'An' : 'A' %> <%= @exception.class %> occurred in background at <%= raw
|
1
|
+
<%= @exception.class.to_s =~ /^[aeiou]/i ? 'An' : 'A' %> <%= @exception.class %> occurred in background at <%= raw @timestamp %> :
|
2
2
|
|
3
3
|
<%= @exception.message %>
|
4
4
|
<%= @backtrace.first %>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<%= raw sections %>
|
6
|
+
<% sections = @sections.map do |section|
|
7
|
+
summary = render(section).strip
|
8
|
+
unless summary.blank?
|
9
|
+
title = render("title", :title => section).strip
|
10
|
+
"#{title}\n\n#{summary.gsub(/^/, " ")}\n\n"
|
11
|
+
end
|
12
|
+
end.join
|
13
|
+
%>
|
14
|
+
<%= raw sections %>
|
@@ -5,32 +5,48 @@
|
|
5
5
|
<title>Exception</title>
|
6
6
|
</head>
|
7
7
|
<body>
|
8
|
-
<pre style="font-size: 12px">
|
9
|
-
<%= @exception.class.to_s =~ /^[aeiou]/i ? 'An' : 'A' %> <%= @exception.class %> occurred in <%= @kontroller.controller_name %>#<%= @kontroller.action_name %>:
|
10
|
-
|
11
|
-
<%= raw @exception.message %>
|
12
|
-
<%= raw @backtrace.first %>
|
13
8
|
|
14
9
|
<%
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
rescue Exception => e
|
24
|
-
title = render("title", :title => section).strip
|
25
|
-
summary = ["ERROR: Failed to generate exception summary:", [e.class.to_s, e.message].join(": "), e.backtrace && e.backtrace.join("\n")].compact.join("\n\n")
|
26
|
-
|
27
|
-
[title, summary.gsub(/^/, " "), nil].join("\n\n")
|
10
|
+
sections_content = @sections.map do |section|
|
11
|
+
begin
|
12
|
+
summary = render(section).strip
|
13
|
+
unless summary.blank?
|
14
|
+
title = render("title", title: section).strip
|
15
|
+
[title, summary]
|
28
16
|
end
|
29
|
-
|
30
|
-
|
17
|
+
rescue Exception => e
|
18
|
+
title = render("title", title: section).strip
|
19
|
+
summary = ["ERROR: Failed to generate exception summary:", [e.class.to_s, e.message].join(": "), e.backtrace && e.backtrace.join("\n")].compact.join("\n\n")
|
20
|
+
[title, summary]
|
21
|
+
end
|
22
|
+
end
|
31
23
|
%>
|
32
24
|
|
33
|
-
|
34
|
-
|
25
|
+
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
26
|
+
<tr><td align="center" valign="top">
|
27
|
+
<table width="650" border="0" cellpadding="0" cellspacing="20">
|
28
|
+
<tr>
|
29
|
+
<td style="padding: 10px; border: 1px solid #eed3d7; background-color: #f2dede">
|
30
|
+
<h3 style="color: #b94a48">
|
31
|
+
<%= @exception.class.to_s =~ /^[aeiou]/i ? 'An' : 'A' %> <%= @exception.class %> occurred in <%= @kontroller.controller_name %>#<%= @kontroller.action_name %>:
|
32
|
+
</h3>
|
33
|
+
<p style="color: #b94a48"><%= @exception.message %></p>
|
34
|
+
<pre style="font-size: 12px; padding: 5px; background-color:#f5f5f5">
|
35
|
+
<%= @backtrace.first %>
|
36
|
+
</pre>
|
37
|
+
</td>
|
38
|
+
</tr>
|
39
|
+
<% sections_content.each do |title, summary| %>
|
40
|
+
<tr>
|
41
|
+
<td style="border-bottom: 1px solid #eeeeee;"><%= raw title %></td>
|
42
|
+
</tr>
|
43
|
+
<tr>
|
44
|
+
<td><%= raw summary %></td>
|
45
|
+
</tr>
|
46
|
+
<% end %>
|
47
|
+
</table>
|
48
|
+
</td></tr>
|
49
|
+
</table>
|
50
|
+
|
35
51
|
</body>
|
36
52
|
</html>
|