exception_notification 3.0.1 → 4.4.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.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/Appraisals +7 -0
  3. data/CHANGELOG.rdoc +129 -1
  4. data/CODE_OF_CONDUCT.md +22 -0
  5. data/CONTRIBUTING.md +29 -1
  6. data/Gemfile +1 -1
  7. data/MIT-LICENSE +23 -0
  8. data/README.md +168 -222
  9. data/Rakefile +5 -11
  10. data/docs/notifiers/campfire.md +50 -0
  11. data/docs/notifiers/custom.md +42 -0
  12. data/docs/notifiers/datadog.md +51 -0
  13. data/docs/notifiers/email.md +195 -0
  14. data/docs/notifiers/google_chat.md +31 -0
  15. data/docs/notifiers/hipchat.md +66 -0
  16. data/docs/notifiers/irc.md +97 -0
  17. data/docs/notifiers/mattermost.md +115 -0
  18. data/docs/notifiers/slack.md +161 -0
  19. data/docs/notifiers/sns.md +37 -0
  20. data/docs/notifiers/teams.md +54 -0
  21. data/docs/notifiers/webhook.md +60 -0
  22. data/examples/sample_app.rb +54 -0
  23. data/examples/sinatra/Gemfile +8 -0
  24. data/examples/sinatra/Gemfile.lock +95 -0
  25. data/examples/sinatra/Procfile +2 -0
  26. data/examples/sinatra/README.md +11 -0
  27. data/examples/sinatra/config.ru +3 -0
  28. data/examples/sinatra/sinatra_app.rb +36 -0
  29. data/exception_notification.gemspec +32 -11
  30. data/gemfiles/rails4_0.gemfile +7 -0
  31. data/gemfiles/rails4_1.gemfile +7 -0
  32. data/gemfiles/rails4_2.gemfile +7 -0
  33. data/gemfiles/rails5_0.gemfile +7 -0
  34. data/gemfiles/rails5_1.gemfile +7 -0
  35. data/gemfiles/rails5_2.gemfile +7 -0
  36. data/gemfiles/rails6_0.gemfile +7 -0
  37. data/lib/exception_notification.rb +11 -0
  38. data/lib/exception_notification/rack.rb +55 -0
  39. data/lib/exception_notification/rails.rb +9 -0
  40. data/lib/exception_notification/resque.rb +22 -0
  41. data/lib/exception_notification/sidekiq.rb +27 -0
  42. data/lib/exception_notification/version.rb +3 -0
  43. data/lib/exception_notifier.rb +137 -61
  44. data/lib/exception_notifier/base_notifier.rb +24 -0
  45. data/lib/exception_notifier/campfire_notifier.rb +16 -11
  46. data/lib/exception_notifier/datadog_notifier.rb +153 -0
  47. data/lib/exception_notifier/email_notifier.rb +196 -0
  48. data/lib/exception_notifier/google_chat_notifier.rb +42 -0
  49. data/lib/exception_notifier/hipchat_notifier.rb +49 -0
  50. data/lib/exception_notifier/irc_notifier.rb +57 -0
  51. data/lib/exception_notifier/mattermost_notifier.rb +72 -0
  52. data/lib/exception_notifier/modules/backtrace_cleaner.rb +11 -0
  53. data/lib/exception_notifier/modules/error_grouping.rb +77 -0
  54. data/lib/exception_notifier/modules/formatter.rb +118 -0
  55. data/lib/exception_notifier/notifier.rb +9 -179
  56. data/lib/exception_notifier/slack_notifier.rb +111 -0
  57. data/lib/exception_notifier/sns_notifier.rb +85 -0
  58. data/lib/exception_notifier/teams_notifier.rb +193 -0
  59. data/lib/exception_notifier/views/exception_notifier/_backtrace.html.erb +3 -1
  60. data/lib/exception_notifier/views/exception_notifier/_data.html.erb +6 -1
  61. data/lib/exception_notifier/views/exception_notifier/_environment.html.erb +8 -6
  62. data/lib/exception_notifier/views/exception_notifier/_environment.text.erb +1 -4
  63. data/lib/exception_notifier/views/exception_notifier/_request.html.erb +36 -5
  64. data/lib/exception_notifier/views/exception_notifier/_request.text.erb +10 -5
  65. data/lib/exception_notifier/views/exception_notifier/_session.html.erb +10 -2
  66. data/lib/exception_notifier/views/exception_notifier/_session.text.erb +2 -2
  67. data/lib/exception_notifier/views/exception_notifier/_title.html.erb +3 -3
  68. data/lib/exception_notifier/views/exception_notifier/background_exception_notification.html.erb +38 -11
  69. data/lib/exception_notifier/views/exception_notifier/background_exception_notification.text.erb +10 -11
  70. data/lib/exception_notifier/views/exception_notifier/exception_notification.html.erb +38 -22
  71. data/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb +2 -3
  72. data/lib/exception_notifier/webhook_notifier.rb +51 -0
  73. data/lib/generators/exception_notification/install_generator.rb +15 -0
  74. data/lib/generators/exception_notification/templates/exception_notification.rb.erb +55 -0
  75. data/test/exception_notification/rack_test.rb +60 -0
  76. data/test/exception_notification/resque_test.rb +52 -0
  77. data/test/exception_notifier/campfire_notifier_test.rb +120 -0
  78. data/test/exception_notifier/datadog_notifier_test.rb +151 -0
  79. data/test/exception_notifier/email_notifier_test.rb +351 -0
  80. data/test/exception_notifier/google_chat_notifier_test.rb +181 -0
  81. data/test/exception_notifier/hipchat_notifier_test.rb +218 -0
  82. data/test/exception_notifier/irc_notifier_test.rb +137 -0
  83. data/test/exception_notifier/mattermost_notifier_test.rb +202 -0
  84. data/test/exception_notifier/modules/error_grouping_test.rb +165 -0
  85. data/test/exception_notifier/modules/formatter_test.rb +150 -0
  86. data/test/exception_notifier/sidekiq_test.rb +38 -0
  87. data/test/exception_notifier/slack_notifier_test.rb +227 -0
  88. data/test/exception_notifier/sns_notifier_test.rb +121 -0
  89. data/test/exception_notifier/teams_notifier_test.rb +90 -0
  90. data/test/exception_notifier/webhook_notifier_test.rb +96 -0
  91. data/test/exception_notifier_test.rb +182 -0
  92. data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.html.erb +0 -0
  93. data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.text.erb +0 -0
  94. data/test/{dummy/app → support}/views/exception_notifier/_new_section.html.erb +0 -0
  95. data/test/{dummy/app → support}/views/exception_notifier/_new_section.text.erb +0 -0
  96. data/test/test_helper.rb +12 -8
  97. metadata +333 -164
  98. data/.gemtest +0 -0
  99. data/Gemfile.lock +0 -122
  100. data/test/background_exception_notification_test.rb +0 -82
  101. data/test/campfire_test.rb +0 -53
  102. data/test/dummy/.gitignore +0 -4
  103. data/test/dummy/Gemfile +0 -33
  104. data/test/dummy/Gemfile.lock +0 -118
  105. data/test/dummy/Rakefile +0 -7
  106. data/test/dummy/app/controllers/application_controller.rb +0 -3
  107. data/test/dummy/app/controllers/posts_controller.rb +0 -30
  108. data/test/dummy/app/helpers/application_helper.rb +0 -2
  109. data/test/dummy/app/helpers/posts_helper.rb +0 -2
  110. data/test/dummy/app/models/post.rb +0 -2
  111. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  112. data/test/dummy/app/views/posts/_form.html.erb +0 -0
  113. data/test/dummy/app/views/posts/new.html.erb +0 -0
  114. data/test/dummy/app/views/posts/show.html.erb +0 -0
  115. data/test/dummy/config.ru +0 -4
  116. data/test/dummy/config/application.rb +0 -42
  117. data/test/dummy/config/boot.rb +0 -6
  118. data/test/dummy/config/database.yml +0 -22
  119. data/test/dummy/config/environment.rb +0 -13
  120. data/test/dummy/config/environments/development.rb +0 -24
  121. data/test/dummy/config/environments/production.rb +0 -49
  122. data/test/dummy/config/environments/test.rb +0 -35
  123. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  124. data/test/dummy/config/initializers/inflections.rb +0 -10
  125. data/test/dummy/config/initializers/mime_types.rb +0 -5
  126. data/test/dummy/config/initializers/secret_token.rb +0 -7
  127. data/test/dummy/config/initializers/session_store.rb +0 -8
  128. data/test/dummy/config/locales/en.yml +0 -5
  129. data/test/dummy/config/routes.rb +0 -3
  130. data/test/dummy/db/migrate/20110729022608_create_posts.rb +0 -15
  131. data/test/dummy/db/schema.rb +0 -24
  132. data/test/dummy/db/seeds.rb +0 -7
  133. data/test/dummy/lib/tasks/.gitkeep +0 -0
  134. data/test/dummy/public/404.html +0 -26
  135. data/test/dummy/public/422.html +0 -26
  136. data/test/dummy/public/500.html +0 -26
  137. data/test/dummy/public/favicon.ico +0 -0
  138. data/test/dummy/public/images/rails.png +0 -0
  139. data/test/dummy/public/index.html +0 -239
  140. data/test/dummy/public/javascripts/application.js +0 -2
  141. data/test/dummy/public/javascripts/controls.js +0 -965
  142. data/test/dummy/public/javascripts/dragdrop.js +0 -974
  143. data/test/dummy/public/javascripts/effects.js +0 -1123
  144. data/test/dummy/public/javascripts/prototype.js +0 -6001
  145. data/test/dummy/public/javascripts/rails.js +0 -191
  146. data/test/dummy/public/robots.txt +0 -5
  147. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  148. data/test/dummy/public/stylesheets/scaffold.css +0 -56
  149. data/test/dummy/script/rails +0 -6
  150. data/test/dummy/test/fixtures/posts.yml +0 -11
  151. data/test/dummy/test/functional/posts_controller_test.rb +0 -239
  152. data/test/dummy/test/test_helper.rb +0 -13
  153. data/test/exception_notification_test.rb +0 -73
@@ -0,0 +1,60 @@
1
+ ### WebHook notifier
2
+
3
+ This notifier ships notifications over the HTTP protocol.
4
+
5
+ #### Usage
6
+
7
+ Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'httparty'
11
+ ```
12
+
13
+ To configure it, you need to set the `url` option, like this:
14
+
15
+ ```ruby
16
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
17
+ email: {
18
+ email_prefix: '[PREFIX] ',
19
+ sender_address: %{"notifier" <notifier@example.com>},
20
+ exception_recipients: %w{exceptions@example.com}
21
+ },
22
+ webhook: {
23
+ url: 'http://domain.com:5555/hubot/path'
24
+ }
25
+ ```
26
+
27
+ By default, the WebhookNotifier will call the URLs using the POST method. But, you can change this using the `http_method` option.
28
+
29
+ ```ruby
30
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
31
+ email: {
32
+ email_prefix: '[PREFIX] ',
33
+ sender_address: %{"notifier" <notifier@example.com>},
34
+ exception_recipients: %w{exceptions@example.com}
35
+ },
36
+ webhook: {
37
+ url: 'http://domain.com:5555/hubot/path',
38
+ http_method: :get
39
+ }
40
+ ```
41
+
42
+ Besides the `url` and `http_method` options, all the other options are passed directly to HTTParty. Thus, if the HTTP server requires authentication, you can include the following options:
43
+
44
+ ```ruby
45
+ Rails.application.config.middleware.use ExceptionNotification::Rack,
46
+ email: {
47
+ email_prefix: '[PREFIX] ',
48
+ sender_address: %{"notifier" <notifier@example.com>},
49
+ exception_recipients: %w{exceptions@example.com}
50
+ },
51
+ webhook: {
52
+ url: 'http://domain.com:5555/hubot/path',
53
+ basic_auth: {
54
+ username: 'alice',
55
+ password: 'password'
56
+ }
57
+ }
58
+ ```
59
+
60
+ For more HTTParty options, check out the [documentation](https://github.com/jnunemaker/httparty).
@@ -0,0 +1,54 @@
1
+ # -------------------------------------------
2
+ # To run the application: ruby examples/sample_app.rb
3
+ # -------------------------------------------
4
+
5
+ require 'bundler/inline'
6
+
7
+ gemfile do
8
+ source 'https://rubygems.org'
9
+
10
+ gem 'rails', '5.0.0'
11
+ gem 'exception_notification', '4.3.0'
12
+ gem 'httparty', '0.15.7'
13
+ end
14
+
15
+ class SampleApp < Rails::Application
16
+ config.middleware.use ExceptionNotification::Rack,
17
+ webhook: {
18
+ url: 'http://example.com'
19
+ }
20
+
21
+ config.secret_key_base = 'my secret key base'
22
+
23
+ Rails.logger = Logger.new($stdout)
24
+
25
+ routes.draw do
26
+ get '/', to: 'exceptions#index'
27
+ end
28
+ end
29
+
30
+ require 'action_controller/railtie'
31
+
32
+ class ExceptionsController < ActionController::Base
33
+ def index
34
+ raise 'Sample exception raised, you should receive a notification!'
35
+ end
36
+ end
37
+
38
+ require 'minitest/autorun'
39
+
40
+ class Test < Minitest::Test
41
+ include Rack::Test::Methods
42
+
43
+ def test_raise_exception
44
+ get '/'
45
+
46
+ assert last_response.server_error?
47
+ end
48
+
49
+ private
50
+
51
+ def app
52
+ Rails.application
53
+ end
54
+ end
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'exception_notification', path: '../../'
4
+
5
+ gem 'foreman'
6
+ gem 'mailcatcher'
7
+ gem 'sinatra', '~> 1.3.5'
8
+ gem 'thin', '~> 1.5.1'
@@ -0,0 +1,95 @@
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)
@@ -0,0 +1,2 @@
1
+ web: bundle exec thin start --port 3000
2
+ mail: bundle exec mailcatcher --foreground --smtp-port 1025 --http-port 1080
@@ -0,0 +1,11 @@
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.
@@ -0,0 +1,3 @@
1
+ require ::File.expand_path('../sinatra_app', __FILE__)
2
+
3
+ run SinatraApp
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'sinatra/base'
4
+ require 'exception_notification'
5
+
6
+ class SinatraApp < Sinatra::Base
7
+ use Rack::Config do |env|
8
+ env['action_dispatch.parameter_filter'] = [:password] # This is highly recommended. It will prevent the ExceptionNotification email from including your users' passwords
9
+ end
10
+
11
+ use ExceptionNotification::Rack,
12
+ email: {
13
+ email_prefix: '[Example] ',
14
+ sender_address: %("notifier" <notifier@example.com>),
15
+ exception_recipients: %w[exceptions@example.com],
16
+ smtp_settings: {
17
+ address: 'localhost',
18
+ port: 1025
19
+ }
20
+ }
21
+
22
+ get '/' do
23
+ raise StandardError, "ERROR: #{params[:error]}" unless params[:error].blank?
24
+
25
+ 'Everything is fine! Now, lets break things clicking <a href="/?error=ops"> here </a>. Dont forget to see the emails at <a href="http://localhost:1080">mailcatcher</a> !'
26
+ end
27
+
28
+ get '/background_notification' do
29
+ begin
30
+ 1 / 0
31
+ rescue StandardError => e
32
+ ExceptionNotifier.notify_exception(e, data: { msg: 'Cannot divide by zero!' })
33
+ end
34
+ 'Check email at <a href="http://localhost:1080">mailcatcher</a>.'
35
+ end
36
+ end
@@ -1,20 +1,41 @@
1
+ require File.expand_path('../lib/exception_notification/version', __FILE__)
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'exception_notification'
3
- s.version = '3.0.1'
4
- s.authors = ["Jamis Buck", "Josh Peek"]
5
- s.date = %q{2013-02-02}
6
- s.summary = "Exception notification for Rails apps"
7
- s.homepage = "http://smartinez87.github.com/exception_notification"
8
- s.email = "smartinez87@gmail.com"
5
+ s.version = ExceptionNotification::VERSION
6
+ s.authors = ['Jamis Buck', 'Josh Peek']
7
+ s.date = '2019-08-16'
8
+ s.summary = 'Exception notification for Rails apps'
9
+ s.homepage = 'https://smartinez87.github.io/exception_notification/'
10
+ s.email = 'smartinez87@gmail.com'
11
+ s.license = 'MIT'
12
+
13
+ s.required_ruby_version = '>= 2.0'
14
+ s.required_rubygems_version = '>= 1.8.11'
9
15
 
10
16
  s.files = `git ls-files`.split("\n")
17
+ s.files -= `git ls-files -- .??*`.split("\n")
11
18
  s.test_files = `git ls-files -- test`.split("\n")
12
19
  s.require_path = 'lib'
13
20
 
14
- s.add_dependency("actionmailer", ">= 3.0.4")
21
+ s.add_dependency('actionmailer', '>= 4.0', '< 7')
22
+ s.add_dependency('activesupport', '>= 4.0', '< 7')
15
23
 
16
- s.add_development_dependency "tinder", "~> 1.8"
17
- s.add_development_dependency "rails", ">= 3.0.4"
18
- s.add_development_dependency "mocha", ">= 0.11.3"
19
- s.add_development_dependency "sqlite3", ">= 1.3.4"
24
+ s.add_development_dependency 'appraisal', '~> 2.2.0'
25
+ s.add_development_dependency 'aws-sdk-sns', '~> 1'
26
+ s.add_development_dependency 'carrier-pigeon', '>= 0.7.0'
27
+ s.add_development_dependency 'coveralls', '~> 0.8.2'
28
+ s.add_development_dependency 'dogapi', '>= 1.23.0'
29
+ s.add_development_dependency 'hipchat', '>= 1.0.0'
30
+ s.add_development_dependency 'httparty', '~> 0.10.2'
31
+ s.add_development_dependency 'mock_redis', '~> 0.18.0'
32
+ s.add_development_dependency 'mocha', '>= 0.13.0'
33
+ s.add_development_dependency 'rails', '>= 4.0', '< 7'
34
+ s.add_development_dependency 'resque', '~> 1.8.0'
35
+ s.add_development_dependency 'rubocop', '0.50.0'
36
+ # Sidekiq 3.2.2 does not support Ruby 1.9.
37
+ s.add_development_dependency 'sidekiq', '~> 3.0.0', '< 3.2.2'
38
+ s.add_development_dependency 'slack-notifier', '>= 1.0.0'
39
+ s.add_development_dependency 'timecop', '~>0.9.0'
40
+ s.add_development_dependency 'tinder', '~> 1.8'
20
41
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails', '~> 4.0.5'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails', '~> 4.1.1'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails', '~> 4.2.0'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails', '~> 5.0.0'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails', '~> 5.1.0'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails', '~> 5.2.0'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.0.0"
6
+
7
+ gemspec path: "../"
@@ -1 +1,12 @@
1
1
  require 'exception_notifier'
2
+ require 'exception_notification/rack'
3
+ require 'exception_notification/version'
4
+
5
+ module ExceptionNotification
6
+ # Alternative way to setup ExceptionNotification.
7
+ # Run 'rails generate exception_notification:install' to create
8
+ # a fresh initializer with all configuration values.
9
+ def self.configure
10
+ yield ExceptionNotifier
11
+ end
12
+ end
@@ -0,0 +1,55 @@
1
+ module ExceptionNotification
2
+ class Rack
3
+ class CascadePassException < RuntimeError; end
4
+
5
+ def initialize(app, options = {})
6
+ @app = app
7
+
8
+ ExceptionNotifier.ignored_exceptions = options.delete(:ignore_exceptions) if options.key?(:ignore_exceptions)
9
+ ExceptionNotifier.error_grouping = options.delete(:error_grouping) if options.key?(:error_grouping)
10
+ ExceptionNotifier.error_grouping_period = options.delete(:error_grouping_period) if options.key?(:error_grouping_period)
11
+ ExceptionNotifier.notification_trigger = options.delete(:notification_trigger) if options.key?(:notification_trigger)
12
+
13
+ if options.key?(:error_grouping_cache)
14
+ ExceptionNotifier.error_grouping_cache = options.delete(:error_grouping_cache)
15
+ elsif defined?(Rails) && Rails.respond_to?(:cache)
16
+ ExceptionNotifier.error_grouping_cache = Rails.cache
17
+ end
18
+
19
+ if options.key?(:ignore_if)
20
+ rack_ignore = options.delete(:ignore_if)
21
+ ExceptionNotifier.ignore_if do |exception, opts|
22
+ opts.key?(:env) && rack_ignore.call(opts[:env], exception)
23
+ end
24
+ end
25
+
26
+ ExceptionNotifier.ignore_crawlers(options.delete(:ignore_crawlers)) if options.key?(:ignore_crawlers)
27
+
28
+ @ignore_cascade_pass = options.delete(:ignore_cascade_pass) { true }
29
+
30
+ options.each do |notifier_name, opts|
31
+ ExceptionNotifier.register_exception_notifier(notifier_name, opts)
32
+ end
33
+ end
34
+
35
+ def call(env)
36
+ _, headers, = response = @app.call(env)
37
+
38
+ if !@ignore_cascade_pass && headers['X-Cascade'] == 'pass'
39
+ msg = "This exception means that the preceding Rack middleware set the 'X-Cascade' header to 'pass' -- in " \
40
+ 'Rails, this often means that the route was not found (404 error).'
41
+ raise CascadePassException, msg
42
+ end
43
+
44
+ response
45
+ rescue Exception => exception
46
+ if ExceptionNotifier.notify_exception(exception, env: env)
47
+ env['exception_notifier.delivered'] = true
48
+ end
49
+
50
+ raise exception unless exception.is_a?(CascadePassException)
51
+
52
+ response
53
+ end
54
+ end
55
+ end