exception_notification 4.5.0 → 4.6.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.
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copied/adapted from https://github.com/airbrake/airbrake/blob/master/lib/airbrake/rake.rb
4
+
5
+ Rake::TaskManager.record_task_metadata = true if Rake.const_defined?(:TaskManager)
6
+
7
+ module ExceptionNotification
8
+ module RakeTaskExtensions
9
+ # A wrapper around the original +#execute+, that catches all errors and
10
+ # passes them on to ExceptionNotifier.
11
+ #
12
+ # rubocop:disable Lint/RescueException
13
+ def execute(args = nil)
14
+ super(args)
15
+ rescue Exception => e
16
+ ExceptionNotifier.notify_exception(e, data: data_for_exception_notifier(e)) unless e.is_a?(SystemExit)
17
+ raise e
18
+ end
19
+ # rubocop:enable Lint/RescueException
20
+
21
+ private
22
+
23
+ def data_for_exception_notifier(exception = nil)
24
+ data = {}
25
+ data[:error_class] = exception.class.name if exception
26
+ data[:error_message] = exception.message if exception
27
+
28
+ data[:rake] = {}
29
+ data[:rake][:rake_command_line] = reconstruct_command_line
30
+ data[:rake][:name] = name
31
+ data[:rake][:timestamp] = timestamp.to_s
32
+ # data[:investigation] = investigation
33
+
34
+ data[:rake][:full_comment] = full_comment if full_comment
35
+ data[:rake][:arg_names] = arg_names if arg_names.any?
36
+ data[:rake][:arg_description] = arg_description if arg_description
37
+ data[:rake][:locations] = locations if locations.any?
38
+ data[:rake][:sources] = sources if sources.any?
39
+
40
+ if prerequisite_tasks.any?
41
+ data[:rake][:prerequisite_tasks] = prerequisite_tasks.map do |p|
42
+ p.__send__(:data_for_exception_notifier)[:rake]
43
+ end
44
+ end
45
+
46
+ data
47
+ end
48
+ # rubocop:enable
49
+
50
+ def reconstruct_command_line
51
+ "rake #{ARGV.join(' ')}"
52
+ end
53
+ end
54
+ end
55
+
56
+ module Rake
57
+ class Task
58
+ prepend ExceptionNotification::RakeTaskExtensions
59
+ end
60
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ExceptionNotification
4
- VERSION = '4.5.0'
4
+ VERSION = '4.6.0'
5
5
  end
@@ -72,6 +72,9 @@ module ExceptionNotifier
72
72
  exception_name = "*#{measure_word}* `#{exception_class}`"
73
73
  env = options[:env]
74
74
 
75
+ options[:headers] ||= {}
76
+ options[:headers]['Content-Type'] = 'application/json'
77
+
75
78
  if env.nil?
76
79
  data = options[:data] || {}
77
80
  text = "#{exception_name} *occured in background*\n"
@@ -38,7 +38,7 @@ module ExceptionNotifier
38
38
  @controller = @request_items = nil
39
39
  else
40
40
  @controller = @env['action_controller.instance'] || MissingController.new
41
-
41
+ @additional_exception_data = @env['exception_notifier.exception_data']
42
42
  request = ActionDispatch::Request.new(@env)
43
43
 
44
44
  @request_items = { url: request.original_url,
@@ -47,10 +47,6 @@ module ExceptionNotifier
47
47
  parameters: request.filtered_parameters,
48
48
  timestamp: Time.current }
49
49
 
50
- if request.session['warden.user.user.key']
51
- current_user = User.find(request.session['warden.user.user.key'][0][0])
52
- @request_items[:current_user] = { id: current_user.id, email: current_user.email }
53
- end
54
50
  end
55
51
 
56
52
  payload = message_text
@@ -96,7 +92,7 @@ module ExceptionNotifier
96
92
 
97
93
  details['facts'].push message_request unless @request_items.nil?
98
94
  details['facts'].push message_backtrace unless @backtrace.nil?
99
-
95
+ details['facts'].push additional_exception_data unless @additional_exception_data.nil?
100
96
  details
101
97
  end
102
98
 
@@ -127,6 +123,13 @@ module ExceptionNotifier
127
123
  }
128
124
  end
129
125
 
126
+ def additional_exception_data
127
+ {
128
+ 'name' => 'Data',
129
+ 'value' => "`#{@additional_exception_data}`\n "
130
+ }
131
+ end
132
+
130
133
  def gitlab_view_link
131
134
  {
132
135
  '@type' => 'ViewAction',
@@ -1,6 +1,6 @@
1
1
  <ul style="list-style: none">
2
2
  <li>
3
3
  <strong>data:</strong>
4
- <span><%= PP.pp(@data, "") %></span>
4
+ <span><%= PP.pp(@data, +"") %></span>
5
5
  </li>
6
6
  </ul>
@@ -1 +1 @@
1
- * data: <%= raw PP.pp(@data, "") %>
1
+ * data: <%= raw PP.pp(@data, +"") %>
@@ -5,6 +5,6 @@
5
5
  </li>
6
6
  <li>
7
7
  <strong>data: </strong>
8
- <span><%= PP.pp(@request.session.to_hash, "") %></span>
8
+ <span><%= PP.pp(@request.session.to_hash, +"") %></span>
9
9
  </li>
10
10
  </ul>
@@ -1,2 +1,2 @@
1
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, "") %>
2
+ * data: <%= raw PP.pp(@request.session.to_hash, +"") %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ExceptionNotification
4
4
  module Generators
5
- class InstallGenerator < Rails::Generators::Base
5
+ class InstallGenerator < ::Rails::Generators::Base
6
6
  desc 'Creates a ExceptionNotification initializer.'
7
7
 
8
8
  source_root File.expand_path('templates', __dir__)
@@ -1,4 +1,6 @@
1
+ # Move this require to your `config/application.rb` if you want to be notified from runner commands too.
1
2
  require 'exception_notification/rails'
3
+ require 'exception_notification/rake'
2
4
  <% if options.sidekiq? %>
3
5
  require 'exception_notification/sidekiq'
4
6
  <% end %>
@@ -19,7 +21,7 @@ ExceptionNotification.configure do |config|
19
21
  # Adds a condition to decide when an exception must be ignored or not.
20
22
  # The ignore_if method can be invoked multiple times to add extra conditions.
21
23
  # config.ignore_if do |exception, options|
22
- # not Rails.env.production?
24
+ # Rails.env.local?
23
25
  # end
24
26
 
25
27
  # Ignore exceptions generated by crawlers
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ require 'rake'
6
+ require 'exception_notification/rake'
7
+
8
+ class RakeTest < ActiveSupport::TestCase
9
+ setup do
10
+ Rake::Task.define_task :dependency_1 do
11
+ puts :dependency_1
12
+ end
13
+ Rake::Task.define_task raise_exception: :dependency_1 do
14
+ raise 'test exception'
15
+ end
16
+ @task = Rake::Task[:raise_exception]
17
+ end
18
+
19
+ test 'notifies of exception' do
20
+ ExceptionNotifier.expects(:notify_exception).with do |ex, opts|
21
+ data = opts[:data]
22
+ ex.is_a?(RuntimeError) &&
23
+ ex.message == 'test exception' &&
24
+ data[:error_class] == 'RuntimeError' &&
25
+ data[:error_message] == 'test exception' &&
26
+ data[:rake][:rake_command_line] == 'rake ' &&
27
+ data[:rake][:name] == 'raise_exception' &&
28
+ data[:rake][:timestamp] &&
29
+ data[:rake][:sources] == ['dependency_1'] &&
30
+ data[:rake][:prerequisite_tasks][0][:name] == 'dependency_1'
31
+ end
32
+
33
+ # The original error is re-raised
34
+ assert_raises(RuntimeError) do
35
+ @task.invoke
36
+ end
37
+ end
38
+ end
@@ -295,8 +295,7 @@ class EmailNotifierWithEnvTest < ActiveSupport::TestCase
295
295
  Environment:
296
296
  -------------------------------
297
297
 
298
- * CONTENT_LENGTH : 0
299
- * HTTPS : on
298
+ * HTTPS : on
300
299
  * HTTP_HOST : test.address
301
300
  * HTTP_USER_AGENT : Rails Testing
302
301
  * PATH_INFO : /
@@ -306,24 +305,19 @@ class EmailNotifierWithEnvTest < ActiveSupport::TestCase
306
305
  * SCRIPT_NAME :
307
306
  * SERVER_NAME : example.org
308
307
  * SERVER_PORT : 80
308
+ * SERVER_PROTOCOL : HTTP/1.1
309
309
  * action_controller.instance : #{@controller}
310
310
  * action_dispatch.parameter_filter : [\"secret\"]
311
- * action_dispatch.request.content_type :
312
311
  * action_dispatch.request.parameters : {"id"=>"foo", "secret"=>"[FILTERED]"}
313
312
  * action_dispatch.request.path_parameters : {}
314
313
  * action_dispatch.request.query_parameters : {"id"=>"foo", "secret"=>"[FILTERED]"}
315
314
  * action_dispatch.request.request_parameters: {}
316
315
  * rack.errors : #{@test_env['rack.errors']}
317
- * rack.input : #{@test_env['rack.input']}
318
- * rack.multiprocess : true
319
- * rack.multithread : true
320
- * rack.request.query_hash : {"id"=>"foo", "secret"=>"[FILTERED]"}
321
- * rack.request.query_string : id=foo&secret=secret
322
- * rack.run_once : false
316
+ * rack.request.form_hash : {}
317
+ * rack.request.form_input :
323
318
  * rack.session : #{@test_env['rack.session']}
324
319
  * rack.session.options : #{@test_env['rack.session.options']}
325
320
  * rack.url_scheme : http
326
- * rack.version : #{Rack::VERSION}
327
321
 
328
322
  -------------------------------
329
323
  Backtrace:
@@ -2,13 +2,7 @@
2
2
 
3
3
  require 'test_helper'
4
4
  require 'rack'
5
-
6
- # silence_warnings trick around require can be removed once
7
- # https://github.com/hipchat/hipchat-rb/pull/174
8
- # gets merged and released
9
- silence_warnings do
10
- require 'hipchat'
11
- end
5
+ require 'hipchat'
12
6
 
13
7
  class HipchatNotifierTest < ActiveSupport::TestCase
14
8
  test 'should send hipchat notification if properly configured' do
@@ -11,7 +11,11 @@ require 'sidekiq/testing'
11
11
  require 'exception_notification/sidekiq'
12
12
 
13
13
  class MockSidekiqServer
14
- include ::Sidekiq::ExceptionHandler
14
+ include ::Sidekiq::Component
15
+
16
+ def config
17
+ Sidekiq.default_configuration
18
+ end
15
19
  end
16
20
 
17
21
  class SidekiqTest < ActiveSupport::TestCase
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
8
8
  - Josh Peek
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-01-20 00:00:00.000000000 Z
12
+ date: 2025-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionmailer
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: '5.2'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '8'
23
+ version: '9'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: '5.2'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '8'
33
+ version: '9'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: activesupport
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -40,7 +40,7 @@ dependencies:
40
40
  version: '5.2'
41
41
  - - "<"
42
42
  - !ruby/object:Gem::Version
43
- version: '8'
43
+ version: '9'
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  version: '5.2'
51
51
  - - "<"
52
52
  - !ruby/object:Gem::Version
53
- version: '8'
53
+ version: '9'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: appraisal
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -200,7 +200,7 @@ dependencies:
200
200
  version: '5.2'
201
201
  - - "<"
202
202
  - !ruby/object:Gem::Version
203
- version: '8'
203
+ version: '9'
204
204
  type: :development
205
205
  prerelease: false
206
206
  version_requirements: !ruby/object:Gem::Requirement
@@ -210,7 +210,7 @@ dependencies:
210
210
  version: '5.2'
211
211
  - - "<"
212
212
  - !ruby/object:Gem::Version
213
- version: '8'
213
+ version: '9'
214
214
  - !ruby/object:Gem::Dependency
215
215
  name: resque
216
216
  requirement: !ruby/object:Gem::Requirement
@@ -229,16 +229,16 @@ dependencies:
229
229
  name: rubocop
230
230
  requirement: !ruby/object:Gem::Requirement
231
231
  requirements:
232
- - - '='
232
+ - - ">="
233
233
  - !ruby/object:Gem::Version
234
- version: 0.78.0
234
+ version: '0'
235
235
  type: :development
236
236
  prerelease: false
237
237
  version_requirements: !ruby/object:Gem::Requirement
238
238
  requirements:
239
- - - '='
239
+ - - ">="
240
240
  - !ruby/object:Gem::Version
241
- version: 0.78.0
241
+ version: '0'
242
242
  - !ruby/object:Gem::Dependency
243
243
  name: sidekiq
244
244
  requirement: !ruby/object:Gem::Requirement
@@ -281,7 +281,7 @@ dependencies:
281
281
  - - "~>"
282
282
  - !ruby/object:Gem::Version
283
283
  version: 0.9.0
284
- description:
284
+ description:
285
285
  email: smartinez87@gmail.com
286
286
  executables: []
287
287
  extensions: []
@@ -292,6 +292,7 @@ files:
292
292
  - CODE_OF_CONDUCT.md
293
293
  - CONTRIBUTING.md
294
294
  - Gemfile
295
+ - Gemfile.lock
295
296
  - MIT-LICENSE
296
297
  - README.md
297
298
  - Rakefile
@@ -307,13 +308,6 @@ files:
307
308
  - docs/notifiers/sns.md
308
309
  - docs/notifiers/teams.md
309
310
  - docs/notifiers/webhook.md
310
- - examples/sample_app.rb
311
- - examples/sinatra/Gemfile
312
- - examples/sinatra/Gemfile.lock
313
- - examples/sinatra/Procfile
314
- - examples/sinatra/README.md
315
- - examples/sinatra/config.ru
316
- - examples/sinatra/sinatra_app.rb
317
311
  - exception_notification.gemspec
318
312
  - gemfiles/rails5_2.gemfile
319
313
  - gemfiles/rails6_0.gemfile
@@ -322,6 +316,8 @@ files:
322
316
  - lib/exception_notification.rb
323
317
  - lib/exception_notification/rack.rb
324
318
  - lib/exception_notification/rails.rb
319
+ - lib/exception_notification/rails/runner_tie.rb
320
+ - lib/exception_notification/rake.rb
325
321
  - lib/exception_notification/resque.rb
326
322
  - lib/exception_notification/sidekiq.rb
327
323
  - lib/exception_notification/version.rb
@@ -360,6 +356,7 @@ files:
360
356
  - lib/generators/exception_notification/install_generator.rb
361
357
  - lib/generators/exception_notification/templates/exception_notification.rb.erb
362
358
  - test/exception_notification/rack_test.rb
359
+ - test/exception_notification/rake_test.rb
363
360
  - test/exception_notification/resque_test.rb
364
361
  - test/exception_notifier/datadog_notifier_test.rb
365
362
  - test/exception_notifier/email_notifier_test.rb
@@ -384,8 +381,9 @@ files:
384
381
  homepage: https://smartinez87.github.io/exception_notification/
385
382
  licenses:
386
383
  - MIT
387
- metadata: {}
388
- post_install_message:
384
+ metadata:
385
+ changelog_uri: https://github.com/smartinez87/exception_notification/blob/master/CHANGELOG.rdoc
386
+ post_install_message:
389
387
  rdoc_options: []
390
388
  require_paths:
391
389
  - lib
@@ -400,12 +398,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
400
398
  - !ruby/object:Gem::Version
401
399
  version: 1.8.11
402
400
  requirements: []
403
- rubygems_version: 3.2.32
404
- signing_key:
401
+ rubygems_version: 3.5.22
402
+ signing_key:
405
403
  specification_version: 4
406
404
  summary: Exception notification for Rails apps
407
405
  test_files:
408
406
  - test/exception_notification/rack_test.rb
407
+ - test/exception_notification/rake_test.rb
409
408
  - test/exception_notification/resque_test.rb
410
409
  - test/exception_notifier/datadog_notifier_test.rb
411
410
  - test/exception_notifier/email_notifier_test.rb
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # -------------------------------------------
4
- # To run the application: ruby examples/sample_app.rb
5
- # -------------------------------------------
6
-
7
- require 'bundler/inline'
8
-
9
- gemfile do
10
- source 'https://rubygems.org'
11
-
12
- gem 'rails', '5.0.0'
13
- gem 'exception_notification', '4.3.0'
14
- gem 'httparty', '0.15.7'
15
- end
16
-
17
- class SampleApp < Rails::Application
18
- config.middleware.use ExceptionNotification::Rack,
19
- webhook: {
20
- url: 'http://example.com'
21
- }
22
-
23
- config.secret_key_base = 'my secret key base'
24
-
25
- Rails.logger = Logger.new($stdout)
26
-
27
- routes.draw do
28
- get '/', to: 'exceptions#index'
29
- end
30
- end
31
-
32
- require 'action_controller/railtie'
33
-
34
- class ExceptionsController < ActionController::Base
35
- def index
36
- raise 'Sample exception raised, you should receive a notification!'
37
- end
38
- end
39
-
40
- require 'minitest/autorun'
41
-
42
- class Test < Minitest::Test
43
- include Rack::Test::Methods
44
-
45
- def test_raise_exception
46
- get '/'
47
-
48
- assert last_response.server_error?
49
- end
50
-
51
- private
52
-
53
- def app
54
- Rails.application
55
- end
56
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gem 'exception_notification', path: '../../'
6
-
7
- gem 'foreman'
8
- gem 'mailcatcher'
9
- gem 'sinatra', '~> 1.3.5'
10
- gem 'thin', '~> 1.5.1'
@@ -1,95 +0,0 @@
1
- PATH
2
- remote: ../../
3
- specs:
4
- exception_notification (3.0.1)
5
- actionmailer (>= 3.0.4)
6
- activesupport (>= 3.0.4)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actionmailer (3.2.13)
12
- actionpack (= 3.2.13)
13
- mail (~> 2.5.3)
14
- actionpack (3.2.13)
15
- activemodel (= 3.2.13)
16
- activesupport (= 3.2.13)
17
- builder (~> 3.0.0)
18
- erubis (~> 2.7.0)
19
- journey (~> 1.0.4)
20
- rack (~> 1.4.5)
21
- rack-cache (~> 1.2)
22
- rack-test (~> 0.6.1)
23
- sprockets (~> 2.2.1)
24
- activemodel (3.2.13)
25
- activesupport (= 3.2.13)
26
- builder (~> 3.0.0)
27
- activesupport (3.2.13)
28
- i18n (= 0.6.1)
29
- multi_json (~> 1.0)
30
- builder (3.0.4)
31
- daemons (1.1.9)
32
- erubis (2.7.0)
33
- eventmachine (1.0.3)
34
- foreman (0.61.0)
35
- thor (>= 0.13.6)
36
- haml (4.0.2)
37
- tilt
38
- hike (1.2.1)
39
- i18n (0.6.1)
40
- journey (1.0.4)
41
- mail (2.5.3)
42
- i18n (>= 0.4.0)
43
- mime-types (~> 1.16)
44
- treetop (~> 1.4.8)
45
- mailcatcher (0.5.11)
46
- activesupport (~> 3.0)
47
- eventmachine (~> 1.0.0)
48
- haml (>= 3.1, < 5)
49
- mail (~> 2.3)
50
- sinatra (~> 1.2)
51
- skinny (~> 0.2.3)
52
- sqlite3 (~> 1.3)
53
- thin (~> 1.5.0)
54
- mime-types (1.22)
55
- multi_json (1.7.2)
56
- polyglot (0.3.3)
57
- rack (1.4.5)
58
- rack-cache (1.2)
59
- rack (>= 0.4)
60
- rack-protection (1.5.0)
61
- rack
62
- rack-test (0.6.2)
63
- rack (>= 1.0)
64
- sinatra (1.3.6)
65
- rack (~> 1.4)
66
- rack-protection (~> 1.3)
67
- tilt (~> 1.3, >= 1.3.3)
68
- skinny (0.2.3)
69
- eventmachine (~> 1.0.0)
70
- thin (~> 1.5.0)
71
- sprockets (2.2.2)
72
- hike (~> 1.2)
73
- multi_json (~> 1.0)
74
- rack (~> 1.0)
75
- tilt (~> 1.1, != 1.3.0)
76
- sqlite3 (1.3.7)
77
- thin (1.5.1)
78
- daemons (>= 1.0.9)
79
- eventmachine (>= 0.12.6)
80
- rack (>= 1.0.0)
81
- thor (0.18.1)
82
- tilt (1.3.6)
83
- treetop (1.4.12)
84
- polyglot
85
- polyglot (>= 0.3.1)
86
-
87
- PLATFORMS
88
- ruby
89
-
90
- DEPENDENCIES
91
- exception_notification!
92
- foreman
93
- mailcatcher
94
- sinatra (~> 1.3.5)
95
- thin (~> 1.5.1)
@@ -1,2 +0,0 @@
1
- web: bundle exec thin start --port 3000
2
- mail: bundle exec mailcatcher --foreground --smtp-port 1025 --http-port 1080
@@ -1,11 +0,0 @@
1
- # Using Exception Notification with Sinatra
2
-
3
- ## Quick start
4
-
5
- git clone git@github.com:smartinez87/exception_notification.git
6
- cd exception_notification/examples/sinatra
7
- bundle install
8
- bundle exec foreman start
9
-
10
-
11
- The last command starts two services, a smtp server and the sinatra app itself. Thus, visit [http://localhost:1080/](http://localhost:1080/) to check the emails sent and, in a separated tab, visit [http://localhost:3000](http://localhost:3000) and cause some errors. For more info, use the [source](https://github.com/smartinez87/exception_notification/blob/master/examples/sinatra/sinatra_app.rb) Luke.
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path('../sinatra_app', __FILE__)
4
-
5
- run SinatraApp
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubygems'
4
- require 'bundler/setup'
5
- require 'sinatra/base'
6
- require 'exception_notification'
7
-
8
- class SinatraApp < Sinatra::Base
9
- use Rack::Config do |env|
10
- # This is highly recommended. It will prevent the ExceptionNotification email from including your users' passwords
11
- env['action_dispatch.parameter_filter'] = [:password]
12
- end
13
-
14
- use ExceptionNotification::Rack,
15
- email: {
16
- email_prefix: '[Example] ',
17
- sender_address: %("notifier" <notifier@example.com>),
18
- exception_recipients: %w[exceptions@example.com],
19
- smtp_settings: {
20
- address: 'localhost',
21
- port: 1025
22
- }
23
- }
24
-
25
- get '/' do
26
- raise StandardError, "ERROR: #{params[:error]}" unless params[:error].blank?
27
-
28
- 'Everything is fine! Now, lets break things clicking <a href="/?error=ops"> here </a>.' \
29
- 'Dont forget to see the emails at <a href="http://localhost:1080">mailcatcher</a> !'
30
- end
31
-
32
- get '/background_notification' do
33
- begin
34
- 1 / 0
35
- rescue StandardError => e
36
- ExceptionNotifier.notify_exception(e, data: { msg: 'Cannot divide by zero!' })
37
- end
38
- 'Check email at <a href="http://localhost:1080">mailcatcher</a>.'
39
- end
40
- end