exception_handling 2.11.3 → 3.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -3
  3. data/.ruby-version +1 -1
  4. data/Gemfile +16 -16
  5. data/Gemfile.lock +114 -110
  6. data/README.md +3 -7
  7. data/Rakefile +11 -8
  8. data/exception_handling.gemspec +10 -12
  9. data/lib/exception_handling/exception_info.rb +10 -13
  10. data/lib/exception_handling/honeybadger_callbacks.rb +59 -0
  11. data/lib/exception_handling/log_stub_error.rb +1 -2
  12. data/lib/exception_handling/methods.rb +53 -6
  13. data/lib/exception_handling/testing.rb +10 -20
  14. data/lib/exception_handling/version.rb +1 -1
  15. data/lib/exception_handling.rb +30 -58
  16. data/semaphore_ci/setup.sh +3 -0
  17. data/{spec → test}/helpers/controller_helpers.rb +0 -0
  18. data/{spec → test}/helpers/exception_helpers.rb +2 -2
  19. data/{spec/spec_helper.rb → test/test_helper.rb} +42 -63
  20. data/test/unit/exception_handling/exception_catalog_test.rb +85 -0
  21. data/test/unit/exception_handling/exception_description_test.rb +82 -0
  22. data/{spec/unit/exception_handling/exception_info_spec.rb → test/unit/exception_handling/exception_info_test.rb} +114 -153
  23. data/test/unit/exception_handling/honeybadger_callbacks_test.rb +122 -0
  24. data/{spec/unit/exception_handling/log_error_stub_spec.rb → test/unit/exception_handling/log_error_stub_test.rb} +22 -38
  25. data/{spec/unit/exception_handling/mailer_spec.rb → test/unit/exception_handling/mailer_test.rb} +18 -17
  26. data/test/unit/exception_handling/methods_test.rb +84 -0
  27. data/test/unit/exception_handling/sensu_test.rb +52 -0
  28. data/test/unit/exception_handling_test.rb +1109 -0
  29. metadata +60 -115
  30. data/.github/workflows/pipeline.yml +0 -33
  31. data/.rspec +0 -3
  32. data/Appraisals +0 -13
  33. data/CHANGELOG.md +0 -109
  34. data/gemfiles/rails_5.gemfile +0 -18
  35. data/gemfiles/rails_6.gemfile +0 -18
  36. data/lib/exception_handling/escalate_callback.rb +0 -19
  37. data/lib/exception_handling/logging_methods.rb +0 -27
  38. data/spec/rake_test_warning_false.rb +0 -20
  39. data/spec/unit/exception_handling/escalate_callback_spec.rb +0 -81
  40. data/spec/unit/exception_handling/exception_catalog_spec.rb +0 -85
  41. data/spec/unit/exception_handling/exception_description_spec.rb +0 -82
  42. data/spec/unit/exception_handling/logging_methods_spec.rb +0 -38
  43. data/spec/unit/exception_handling/methods_spec.rb +0 -105
  44. data/spec/unit/exception_handling/sensu_spec.rb +0 -51
  45. data/spec/unit/exception_handling_spec.rb +0 -1254
metadata CHANGED
@@ -1,103 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_handling
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.3
4
+ version: 3.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
- - Invoca
8
- autorequire:
7
+ - Colin Kelley
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-07 00:00:00.000000000 Z
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '5.2'
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '7.0'
19
+ version: '4.2'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '5.2'
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '7.0'
26
+ version: '4.2'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: actionpack
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '5.2'
40
- - - "<"
31
+ - - "~>"
41
32
  - !ruby/object:Gem::Version
42
- version: '7.0'
33
+ version: '4.2'
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
46
37
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '5.2'
50
- - - "<"
38
+ - - "~>"
51
39
  - !ruby/object:Gem::Version
52
- version: '7.0'
40
+ version: '4.2'
53
41
  - !ruby/object:Gem::Dependency
54
42
  name: activesupport
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: '5.2'
60
- - - "<"
61
- - !ruby/object:Gem::Version
62
- version: '7.0'
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '5.2'
70
- - - "<"
71
- - !ruby/object:Gem::Version
72
- version: '7.0'
73
- - !ruby/object:Gem::Dependency
74
- name: contextual_logger
75
43
  requirement: !ruby/object:Gem::Requirement
76
44
  requirements:
77
45
  - - "~>"
78
46
  - !ruby/object:Gem::Version
79
- version: '1.0'
47
+ version: '4.2'
80
48
  type: :runtime
81
49
  prerelease: false
82
50
  version_requirements: !ruby/object:Gem::Requirement
83
51
  requirements:
84
52
  - - "~>"
85
53
  - !ruby/object:Gem::Version
86
- version: '1.0'
54
+ version: '4.2'
87
55
  - !ruby/object:Gem::Dependency
88
- name: escalate
56
+ name: contextual_logger
89
57
  requirement: !ruby/object:Gem::Requirement
90
58
  requirements:
91
- - - "~>"
59
+ - - ">="
92
60
  - !ruby/object:Gem::Version
93
- version: '0.3'
61
+ version: '0'
94
62
  type: :runtime
95
63
  prerelease: false
96
64
  version_requirements: !ruby/object:Gem::Requirement
97
65
  requirements:
98
- - - "~>"
66
+ - - ">="
99
67
  - !ruby/object:Gem::Version
100
- version: '0.3'
68
+ version: '0'
101
69
  - !ruby/object:Gem::Dependency
102
70
  name: eventmachine
103
71
  requirement: !ruby/object:Gem::Requirement
@@ -113,61 +81,43 @@ dependencies:
113
81
  - !ruby/object:Gem::Version
114
82
  version: '1.0'
115
83
  - !ruby/object:Gem::Dependency
116
- name: invoca-utils
84
+ name: hobo_support
117
85
  requirement: !ruby/object:Gem::Requirement
118
86
  requirements:
119
- - - "~>"
87
+ - - ">="
120
88
  - !ruby/object:Gem::Version
121
- version: '0.3'
89
+ version: '0'
122
90
  type: :runtime
123
91
  prerelease: false
124
92
  version_requirements: !ruby/object:Gem::Requirement
125
93
  requirements:
126
- - - "~>"
94
+ - - ">="
127
95
  - !ruby/object:Gem::Version
128
- version: '0.3'
96
+ version: '0'
129
97
  - !ruby/object:Gem::Dependency
130
- name: psych
98
+ name: invoca-utils
131
99
  requirement: !ruby/object:Gem::Requirement
132
100
  requirements:
133
101
  - - "~>"
134
102
  - !ruby/object:Gem::Version
135
- version: '3.0'
103
+ version: '0.0'
136
104
  type: :runtime
137
105
  prerelease: false
138
106
  version_requirements: !ruby/object:Gem::Requirement
139
107
  requirements:
140
108
  - - "~>"
141
109
  - !ruby/object:Gem::Version
142
- version: '3.0'
143
- - !ruby/object:Gem::Dependency
144
- name: net-smtp
145
- requirement: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
- type: :runtime
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- requirements:
154
- - - ">="
155
- - !ruby/object:Gem::Version
156
- version: '0'
110
+ version: '0.0'
157
111
  description: Exception handling logger/emailer
158
112
  email:
159
- - development@invoca.com
113
+ - colindkelley@gmail.com
160
114
  executables: []
161
115
  extensions: []
162
116
  extra_rdoc_files: []
163
117
  files:
164
- - ".github/workflows/pipeline.yml"
165
118
  - ".gitignore"
166
- - ".rspec"
167
119
  - ".rubocop.yml"
168
120
  - ".ruby-version"
169
- - Appraisals
170
- - CHANGELOG.md
171
121
  - Gemfile
172
122
  - Gemfile.lock
173
123
  - LICENSE
@@ -175,34 +125,30 @@ files:
175
125
  - Rakefile
176
126
  - config/exception_filters.yml
177
127
  - exception_handling.gemspec
178
- - gemfiles/rails_5.gemfile
179
- - gemfiles/rails_6.gemfile
180
128
  - lib/exception_handling.rb
181
- - lib/exception_handling/escalate_callback.rb
182
129
  - lib/exception_handling/exception_catalog.rb
183
130
  - lib/exception_handling/exception_description.rb
184
131
  - lib/exception_handling/exception_info.rb
132
+ - lib/exception_handling/honeybadger_callbacks.rb
185
133
  - lib/exception_handling/log_stub_error.rb
186
- - lib/exception_handling/logging_methods.rb
187
134
  - lib/exception_handling/mailer.rb
188
135
  - lib/exception_handling/methods.rb
189
136
  - lib/exception_handling/sensu.rb
190
137
  - lib/exception_handling/testing.rb
191
138
  - lib/exception_handling/version.rb
192
- - spec/helpers/controller_helpers.rb
193
- - spec/helpers/exception_helpers.rb
194
- - spec/rake_test_warning_false.rb
195
- - spec/spec_helper.rb
196
- - spec/unit/exception_handling/escalate_callback_spec.rb
197
- - spec/unit/exception_handling/exception_catalog_spec.rb
198
- - spec/unit/exception_handling/exception_description_spec.rb
199
- - spec/unit/exception_handling/exception_info_spec.rb
200
- - spec/unit/exception_handling/log_error_stub_spec.rb
201
- - spec/unit/exception_handling/logging_methods_spec.rb
202
- - spec/unit/exception_handling/mailer_spec.rb
203
- - spec/unit/exception_handling/methods_spec.rb
204
- - spec/unit/exception_handling/sensu_spec.rb
205
- - spec/unit/exception_handling_spec.rb
139
+ - semaphore_ci/setup.sh
140
+ - test/helpers/controller_helpers.rb
141
+ - test/helpers/exception_helpers.rb
142
+ - test/test_helper.rb
143
+ - test/unit/exception_handling/exception_catalog_test.rb
144
+ - test/unit/exception_handling/exception_description_test.rb
145
+ - test/unit/exception_handling/exception_info_test.rb
146
+ - test/unit/exception_handling/honeybadger_callbacks_test.rb
147
+ - test/unit/exception_handling/log_error_stub_test.rb
148
+ - test/unit/exception_handling/mailer_test.rb
149
+ - test/unit/exception_handling/methods_test.rb
150
+ - test/unit/exception_handling/sensu_test.rb
151
+ - test/unit/exception_handling_test.rb
206
152
  - views/exception_handling/mailer/escalate_custom.html.erb
207
153
  - views/exception_handling/mailer/escalation_notification.html.erb
208
154
  - views/exception_handling/mailer/log_parser_exception_notification.html.erb
@@ -211,7 +157,7 @@ licenses: []
211
157
  metadata:
212
158
  source_code_uri: https://github.com/Invoca/exception_handling
213
159
  allowed_push_host: https://rubygems.org
214
- post_install_message:
160
+ post_install_message:
215
161
  rdoc_options: []
216
162
  require_paths:
217
163
  - lib
@@ -222,27 +168,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
168
  version: '0'
223
169
  required_rubygems_version: !ruby/object:Gem::Requirement
224
170
  requirements:
225
- - - ">="
171
+ - - ">"
226
172
  - !ruby/object:Gem::Version
227
- version: '0'
173
+ version: 1.3.1
228
174
  requirements: []
229
- rubygems_version: 3.1.6
230
- signing_key:
175
+ rubyforge_project:
176
+ rubygems_version: 2.6.13
177
+ signing_key:
231
178
  specification_version: 4
232
179
  summary: Invoca's exception handling logger/emailer layer, based on exception_notifier.
233
180
  Works with Rails or EventMachine or EventMachine+Synchrony.
234
181
  test_files:
235
- - spec/helpers/controller_helpers.rb
236
- - spec/helpers/exception_helpers.rb
237
- - spec/rake_test_warning_false.rb
238
- - spec/spec_helper.rb
239
- - spec/unit/exception_handling/escalate_callback_spec.rb
240
- - spec/unit/exception_handling/exception_catalog_spec.rb
241
- - spec/unit/exception_handling/exception_description_spec.rb
242
- - spec/unit/exception_handling/exception_info_spec.rb
243
- - spec/unit/exception_handling/log_error_stub_spec.rb
244
- - spec/unit/exception_handling/logging_methods_spec.rb
245
- - spec/unit/exception_handling/mailer_spec.rb
246
- - spec/unit/exception_handling/methods_spec.rb
247
- - spec/unit/exception_handling/sensu_spec.rb
248
- - spec/unit/exception_handling_spec.rb
182
+ - test/helpers/controller_helpers.rb
183
+ - test/helpers/exception_helpers.rb
184
+ - test/test_helper.rb
185
+ - test/unit/exception_handling/exception_catalog_test.rb
186
+ - test/unit/exception_handling/exception_description_test.rb
187
+ - test/unit/exception_handling/exception_info_test.rb
188
+ - test/unit/exception_handling/honeybadger_callbacks_test.rb
189
+ - test/unit/exception_handling/log_error_stub_test.rb
190
+ - test/unit/exception_handling/mailer_test.rb
191
+ - test/unit/exception_handling/methods_test.rb
192
+ - test/unit/exception_handling/sensu_test.rb
193
+ - test/unit/exception_handling_test.rb
@@ -1,33 +0,0 @@
1
- ---
2
- name: Pipeline
3
- on: [push]
4
- jobs:
5
- tests:
6
- name: Unit Tests
7
- runs-on: ubuntu-latest
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: [2.5, 2.6, 2.7, '3.0', 3.1]
12
- gemfile:
13
- - Gemfile
14
- - gemfiles/rails_5.gemfile
15
- - gemfiles/rails_6.gemfile
16
- exclude:
17
- - gemfile: Gemfile
18
- ruby: 2.5
19
- - gemfile: gemfiles/rails_5.gemfile
20
- ruby: '3.0'
21
- - gemfile: gemfiles/rails_5.gemfile
22
- ruby: 3.1
23
- env:
24
- BUNDLE_GEMFILE: ${{ matrix.gemfile }}
25
- steps:
26
- - uses: actions/checkout@v2
27
- - uses: ruby/setup-ruby@v1
28
- with:
29
- ruby-version: ${{ matrix.ruby }}
30
- bundler: 2.2.29
31
- bundler-cache: true
32
- - name: Unit tests
33
- run: bundle exec rspec
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --require spec_helper
2
- --format progress
3
- --color
data/Appraisals DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise "rails-5" do
4
- gem 'actionmailer', '~> 5.2'
5
- gem 'actionpack', '~> 5.2'
6
- gem 'activesupport', '~> 5.2'
7
- end
8
-
9
- appraise "rails-6" do
10
- gem 'actionmailer', '~> 6.0'
11
- gem 'actionpack', '~> 6.0'
12
- gem 'activesupport', '~> 6.0'
13
- end
data/CHANGELOG.md DELETED
@@ -1,109 +0,0 @@
1
- # CHANGELOG for `exception_handling`
2
-
3
- Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
-
5
- Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
-
7
- ## [2.11.3] - 2022-04-07
8
- ### Fixed
9
- - Fixed bug in ruby 2.7+ where `digest` was not required by default
10
-
11
- ## [2.11.2] - 2022-04-04
12
- ### Fixed
13
- - Fixed Ruby 3+ bug where arguments where not being passed using ** operator when writing to the logger
14
-
15
- ## [2.11.1] - 2022-04-04
16
- ### Fixed
17
- - Fixed bug in ruby 3+ where `contextual_logger` was missing ruby 3+ support
18
-
19
- ## [2.11.0] - 2022-03-29
20
- ### Added
21
- - Added support for rails 2.7 and 3+
22
-
23
- ### Removed
24
- - Removed support for Rails 4
25
-
26
- ## [2.10.0] - 2022-03-09
27
- ### Removed
28
- - Remove custom object inspection
29
- This removed Honeybadger-specific callbacks (`lib/exception_handling/honeybadger_callbacks.rb`)
30
-
31
- ### Deprecated
32
- - Deprecated use of Honeybadger fork
33
-
34
- ## [2.9.0] - 2020-03-02
35
- ### Added
36
- - Automatically registers with the `escalate` gem's `on_escalate` callback.
37
-
38
- ## [2.8.1] - 2020-12-01
39
- ### Added
40
- - If the `log_context` key `honeybadger_grouping:` is set, pass that value to the `controller:` keyword argument of `HoneyBadger.notify`.
41
-
42
- ## [2.8.0] - 2020-10-19
43
- ### Deprecated
44
- - Deprecated Email Escalation Methods: `escalate_to_production_support`, `escalate_error`, `escalate_warning`, `ensure_escalation`
45
-
46
- ## [2.7.0] - 2020-10-14
47
- ### Added
48
- - Added `LoggingMethods` as a replacement for `Methods` without setting controller or checking for long controller action.
49
- ### Deprecated
50
- - Deprecated `Methods` in favor of `LoggingMethods`.
51
-
52
- ## [2.6.1] - 2020-10-14
53
- ### Fixed
54
- - Fixed honeybadger_context_data to always merge `current_context_for_thread`, even if `log_context:` is passed as `nil`.
55
-
56
- ## [2.6.0] - 2020-08-26
57
- ### Changed
58
- - Calling `log_warning` will now log with Severity::WARNING rather than FATAL.
59
- - Reordered the logging to put the exception class next to the message.
60
-
61
- ## [2.5.0] - 2020-08-19
62
- ### Added
63
- - The `**log_context` passed to `log_error`/`log_warning`/`log_info` is now
64
- passed into `Honeybadger.notify()`, in `context: { log_context: ... }`.
65
-
66
- ### Fixed
67
- - Silenced test warning noise by no longer running ruby -w.
68
- - Renamed a constant to ALLOWLIST.
69
-
70
- ## [2.4.4] - 2020-08-10
71
- ### Fixed
72
- - `ExceptionHandling.logger = nil` no longer displays an "implicit extend" deprecation warning.
73
-
74
- ## [2.4.3] - 2020-05-14
75
- ### Deprecated
76
- - In `ExceptionHandling.logger=`, implicit `logger.extend ContextualLogger::LoggerMixin` is now deprecated.
77
- This will be removed in version 3.0 and an `ArgumentError` will be raised if the logger
78
- doesn't have that mixin. Instead of this implicit behavior, you should explicitly either `extend`
79
- your logger instance or `include` that mixin into your `Logger` class.
80
-
81
- ## [2.4.2] - 2020-05-11
82
- ### Added
83
- - Added support for rails 5 and 6.
84
- - Added appraisal tests for all supported rails version: 4/5/6
85
-
86
- ### Changed
87
- - Updated various test to be compatible with rails version 4/5/6
88
- - Updated the CI pipeline to test against all three supported versions of rails
89
-
90
- ## [2.4.1] - 2020-04-29
91
- ### Changed
92
- - No longer depends on hobo_support. Uses invoca-utils 0.3 instead.
93
-
94
- [2.11.3]: https://github.com/Invoca/exception_handling/compare/v2.11.2...v2.11.3
95
- [2.11.2]: https://github.com/Invoca/exception_handling/compare/v2.11.1...v2.11.2
96
- [2.11.1]: https://github.com/Invoca/exception_handling/compare/v2.11.0...v2.11.1
97
- [2.11.0]: https://github.com/Invoca/exception_handling/compare/v2.10.0...v2.11.0
98
- [2.10.0]: https://github.com/Invoca/exception_handling/compare/v2.9.0...v2.10.0
99
- [2.9.0]: https://github.com/Invoca/exception_handling/compare/v2.8.1...v2.9.0
100
- [2.8.1]: https://github.com/Invoca/exception_handling/compare/v2.8.0...v2.8.1
101
- [2.8.0]: https://github.com/Invoca/exception_handling/compare/v2.7.0...v2.8.0
102
- [2.7.0]: https://github.com/Invoca/exception_handling/compare/v2.6.1...v2.7.0
103
- [2.6.1]: https://github.com/Invoca/exception_handling/compare/v2.6.0...v2.6.1
104
- [2.6.0]: https://github.com/Invoca/exception_handling/compare/v2.5.0...v2.6.0
105
- [2.5.0]: https://github.com/Invoca/exception_handling/compare/v2.4.4...v2.5.0
106
- [2.4.4]: https://github.com/Invoca/exception_handling/compare/v2.4.3...v2.4.4
107
- [2.4.3]: https://github.com/Invoca/exception_handling/compare/v2.4.2...v2.4.3
108
- [2.4.2]: https://github.com/Invoca/exception_handling/compare/v2.4.1...v2.4.2
109
- [2.4.1]: https://github.com/Invoca/exception_handling/compare/v2.4.0...v2.4.1
@@ -1,18 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "actionmailer", "~> 5.2"
6
- gem "activesupport", "~> 5.2"
7
- gem "appraisal", "~> 2.2"
8
- gem "honeybadger", "~> 4.11"
9
- gem "pry"
10
- gem "pry-byebug"
11
- gem "rake"
12
- gem "rspec"
13
- gem "rspec_junit_formatter"
14
- gem "rubocop"
15
- gem "test-unit"
16
- gem "actionpack", "~> 5.2"
17
-
18
- gemspec path: "../"
@@ -1,18 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "actionmailer", "~> 6.0"
6
- gem "activesupport", "~> 6.0"
7
- gem "appraisal", "~> 2.2"
8
- gem "honeybadger", "~> 4.11"
9
- gem "pry"
10
- gem "pry-byebug"
11
- gem "rake"
12
- gem "rspec"
13
- gem "rspec_junit_formatter"
14
- gem "rubocop"
15
- gem "test-unit"
16
- gem "actionpack", "~> 6.0"
17
-
18
- gemspec path: "../"
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'escalate'
4
-
5
- module ExceptionHandling
6
- module EscalateCallback
7
- class << self
8
- def register_if_configured!
9
- register! if ::ExceptionHandling.configured?
10
- end
11
-
12
- def register!
13
- Escalate.on_escalate(log_first: false) do |exception, location_message, **context|
14
- ::ExceptionHandling.log_error(exception, location_message, **context)
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/concern'
4
- require 'active_support/core_ext/module/delegation.rb'
5
-
6
- module ExceptionHandling
7
- module LoggingMethods # included on models and controllers
8
- extend ActiveSupport::Concern
9
-
10
- protected
11
-
12
- delegate :log_error_rack, :log_warning, :log_info, :log_debug, :escalate_error, :escalate_warning, :ensure_escalation, :alert_warning, :log_error, to: ExceptionHandling
13
-
14
- def ensure_safe(exception_context = "")
15
- yield
16
- rescue => ex
17
- log_error ex, exception_context
18
- nil
19
- end
20
-
21
- def ensure_alert(*args)
22
- ExceptionHandling.ensure_alert(*args) do
23
- yield
24
- end
25
- end
26
- end
27
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Rake 11+ has a misfeature where @warning = true by default
4
- # See https://github.com/ruby/rake/pull/97/files
5
- # This causes all tests to be run with `ruby -w`, causing a huge number of warnings
6
- # from gems we don't control and overwhelming our test output.
7
- # This patch reverts that.
8
-
9
- _ = Rake::TestTask
10
-
11
- class Rake::TestTask
12
- module SetWarningFalseMixin
13
- def initialize(*args)
14
- super
15
- self.warning = false
16
- end
17
- end
18
-
19
- prepend SetWarningFalseMixin
20
- end
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'exception_handling/escalate_callback'
4
- require File.expand_path('../../spec_helper', __dir__)
5
-
6
- module ExceptionHandling
7
- describe EscalateCallback do
8
- before do
9
- class TestGem
10
- class << self
11
- attr_accessor :logger
12
- end
13
- include Escalate.mixin
14
- end
15
- TestGem.logger = logger
16
- Escalate.clear_on_escalate_callbacks
17
- end
18
-
19
- after do
20
- Escalate.clear_on_escalate_callbacks
21
- end
22
-
23
- let(:exception) do
24
- raise "boom!"
25
- rescue => ex
26
- ex
27
- end
28
- let(:location_message) { "happened in TestGem" }
29
- let(:context_hash) { { cuid: 'AABBCD' } }
30
- let(:logger) { double("logger") }
31
-
32
- describe '.register_if_configured!' do
33
- context 'when already configured' do
34
- before do
35
- @original_logger = ExceptionHandling.logger
36
- ExceptionHandling.logger = ::Logger.new('/dev/null')
37
- end
38
-
39
- after do
40
- ExceptionHandling.logger = @original_logger
41
- end
42
-
43
- it 'registers a callback' do
44
- EscalateCallback.register_if_configured!
45
-
46
- expect(logger).to_not receive(:error)
47
- expect(logger).to_not receive(:fatal)
48
- expect(ExceptionHandling).to receive(:log_error).with(exception, location_message, context_hash)
49
-
50
- TestGem.escalate(exception, location_message, context: context_hash)
51
- end
52
- end
53
-
54
- context 'when not yet configured' do
55
- before do
56
- @original_logger = ExceptionHandling.logger
57
- ExceptionHandling.logger = nil
58
- end
59
-
60
- after do
61
- ExceptionHandling.logger = @original_logger
62
- end
63
-
64
- it 'registers a callback once the logger is set' do
65
- EscalateCallback.register_if_configured!
66
-
67
- expect(Escalate.on_escalate_callbacks).to be_empty
68
-
69
- ExceptionHandling.logger = ::Logger.new('/dev/null')
70
- expect(Escalate.on_escalate_callbacks).to_not be_empty
71
-
72
- expect(logger).to_not receive(:error)
73
- expect(logger).to_not receive(:fatal)
74
- expect(ExceptionHandling).to receive(:log_error).with(exception, location_message, context_hash)
75
-
76
- TestGem.escalate(exception, location_message, context: context_hash)
77
- end
78
- end
79
- end
80
- end
81
- end