exception_handling 2.10.0 → 2.11.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.
- checksums.yaml +4 -4
- data/.github/workflows/pipeline.yml +9 -3
- data/.ruby-version +1 -1
- data/Appraisals +0 -6
- data/CHANGELOG.md +20 -1
- data/Gemfile.lock +45 -34
- data/exception_handling.gemspec +6 -4
- data/gemfiles/rails_5.gemfile +1 -1
- data/gemfiles/rails_6.gemfile +1 -1
- data/lib/exception_handling/version.rb +1 -1
- data/lib/exception_handling.rb +18 -18
- data/spec/helpers/exception_helpers.rb +1 -1
- data/spec/unit/exception_handling/exception_catalog_spec.rb +1 -1
- data/spec/unit/exception_handling/methods_spec.rb +1 -1
- data/spec/unit/exception_handling_spec.rb +29 -24
- metadata +39 -12
- data/gemfiles/rails_4.gemfile +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 316ced9b4f0224f3754c6214f4007f4fdd1e21a8aaeebfc145792eb418a8b577
|
4
|
+
data.tar.gz: 9d75e6bb79c29ec712832154dfbb64cd1ab786708b5e4591dbb84966c427c9f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e61d34cf62836872573f456cb72438de47332c60a642f7d30635375288f388718c9bd04b717e780236d56aa0ed78e27d4429d2db3df616c982188ff8cec8b90
|
7
|
+
data.tar.gz: 9b004abd4b56e48706784aeaaae6cdeef4ee654f5ea241fa2823cbc307ec717cebc8c19ce455d7fc9d710d119a7c5a6ed5810d953d78cd62a74c1dfdc1d8b5ef
|
@@ -8,12 +8,18 @@ jobs:
|
|
8
8
|
strategy:
|
9
9
|
fail-fast: false
|
10
10
|
matrix:
|
11
|
-
ruby: [2.5, 2.6]
|
11
|
+
ruby: [2.5, 2.6, 2.7, '3.0', 3.1]
|
12
12
|
gemfile:
|
13
13
|
- Gemfile
|
14
|
-
- gemfiles/rails_4.gemfile
|
15
14
|
- gemfiles/rails_5.gemfile
|
16
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
|
17
23
|
env:
|
18
24
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
19
25
|
steps:
|
@@ -21,7 +27,7 @@ jobs:
|
|
21
27
|
- uses: ruby/setup-ruby@v1
|
22
28
|
with:
|
23
29
|
ruby-version: ${{ matrix.ruby }}
|
24
|
-
bundler:
|
30
|
+
bundler: 2.2.29
|
25
31
|
bundler-cache: true
|
26
32
|
- name: Unit tests
|
27
33
|
run: bundle exec rspec
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.5
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,21 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [2.11.2] - 2022-04-04
|
8
|
+
### Fixed
|
9
|
+
- Fixed Ruby 3+ bug where arguments where not being passed using ** operator when writing to the logger
|
10
|
+
|
11
|
+
## [2.11.1] - 2022-04-04
|
12
|
+
### Fixed
|
13
|
+
- Fixed bug in ruby 3+ where `contextual_logger` was missing ruby 3+ support
|
14
|
+
|
15
|
+
## [2.11.0] - 2022-03-29
|
16
|
+
### Added
|
17
|
+
- Added support for rails 2.7 and 3+
|
18
|
+
|
19
|
+
### Removed
|
20
|
+
- Removed support for Rails 4
|
21
|
+
|
7
22
|
## [2.10.0] - 2022-03-09
|
8
23
|
### Removed
|
9
24
|
- Remove custom object inspection
|
@@ -57,7 +72,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
57
72
|
- In `ExceptionHandling.logger=`, implicit `logger.extend ContextualLogger::LoggerMixin` is now deprecated.
|
58
73
|
This will be removed in version 3.0 and an `ArgumentError` will be raised if the logger
|
59
74
|
doesn't have that mixin. Instead of this implicit behavior, you should explicitly either `extend`
|
60
|
-
your logger instance or `include` that mixin into your `Logger` class.
|
75
|
+
your logger instance or `include` that mixin into your `Logger` class.
|
61
76
|
|
62
77
|
## [2.4.2] - 2020-05-11
|
63
78
|
### Added
|
@@ -72,6 +87,10 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
72
87
|
### Changed
|
73
88
|
- No longer depends on hobo_support. Uses invoca-utils 0.3 instead.
|
74
89
|
|
90
|
+
[2.11.2]: https://github.com/Invoca/exception_handling/compare/v2.11.1...v2.11.2
|
91
|
+
[2.11.1]: https://github.com/Invoca/exception_handling/compare/v2.11.0...v2.11.1
|
92
|
+
[2.11.0]: https://github.com/Invoca/exception_handling/compare/v2.10.0...v2.11.0
|
93
|
+
[2.10.0]: https://github.com/Invoca/exception_handling/compare/v2.9.0...v2.10.0
|
75
94
|
[2.9.0]: https://github.com/Invoca/exception_handling/compare/v2.8.1...v2.9.0
|
76
95
|
[2.8.1]: https://github.com/Invoca/exception_handling/compare/v2.8.0...v2.8.1
|
77
96
|
[2.8.0]: https://github.com/Invoca/exception_handling/compare/v2.7.0...v2.8.0
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,43 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
exception_handling (2.
|
5
|
-
actionmailer (>=
|
6
|
-
actionpack (>=
|
7
|
-
activesupport (>=
|
8
|
-
contextual_logger (~> 0
|
4
|
+
exception_handling (2.11.2)
|
5
|
+
actionmailer (>= 5.2, < 7.0)
|
6
|
+
actionpack (>= 5.2, < 7.0)
|
7
|
+
activesupport (>= 5.2, < 7.0)
|
8
|
+
contextual_logger (~> 1.0)
|
9
9
|
escalate (~> 0.3)
|
10
10
|
eventmachine (~> 1.0)
|
11
11
|
invoca-utils (~> 0.3)
|
12
|
+
net-smtp
|
13
|
+
psych (~> 3.0)
|
12
14
|
|
13
15
|
GEM
|
14
16
|
remote: https://rubygems.org/
|
15
17
|
specs:
|
16
|
-
actionmailer (6.0.
|
17
|
-
actionpack (= 6.0.
|
18
|
-
actionview (= 6.0.
|
19
|
-
activejob (= 6.0.
|
18
|
+
actionmailer (6.0.4.7)
|
19
|
+
actionpack (= 6.0.4.7)
|
20
|
+
actionview (= 6.0.4.7)
|
21
|
+
activejob (= 6.0.4.7)
|
20
22
|
mail (~> 2.5, >= 2.5.4)
|
21
23
|
rails-dom-testing (~> 2.0)
|
22
|
-
actionpack (6.0.
|
23
|
-
actionview (= 6.0.
|
24
|
-
activesupport (= 6.0.
|
24
|
+
actionpack (6.0.4.7)
|
25
|
+
actionview (= 6.0.4.7)
|
26
|
+
activesupport (= 6.0.4.7)
|
25
27
|
rack (~> 2.0, >= 2.0.8)
|
26
28
|
rack-test (>= 0.6.3)
|
27
29
|
rails-dom-testing (~> 2.0)
|
28
30
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
29
|
-
actionview (6.0.
|
30
|
-
activesupport (= 6.0.
|
31
|
+
actionview (6.0.4.7)
|
32
|
+
activesupport (= 6.0.4.7)
|
31
33
|
builder (~> 3.1)
|
32
34
|
erubi (~> 1.4)
|
33
35
|
rails-dom-testing (~> 2.0)
|
34
36
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
35
|
-
activejob (6.0.
|
36
|
-
activesupport (= 6.0.
|
37
|
+
activejob (6.0.4.7)
|
38
|
+
activesupport (= 6.0.4.7)
|
37
39
|
globalid (>= 0.3.6)
|
38
|
-
activesupport (6.0.
|
40
|
+
activesupport (6.0.4.7)
|
39
41
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
40
42
|
i18n (>= 0.7, < 2)
|
41
43
|
minitest (~> 5.1)
|
@@ -49,34 +51,41 @@ GEM
|
|
49
51
|
builder (3.2.4)
|
50
52
|
byebug (11.1.3)
|
51
53
|
coderay (1.1.2)
|
52
|
-
concurrent-ruby (1.1.
|
53
|
-
contextual_logger (0.
|
54
|
+
concurrent-ruby (1.1.10)
|
55
|
+
contextual_logger (1.0.0)
|
54
56
|
activesupport
|
55
57
|
json
|
56
58
|
crass (1.0.6)
|
57
|
-
diff-lcs (1.
|
59
|
+
diff-lcs (1.5.0)
|
60
|
+
digest (3.1.0)
|
58
61
|
erubi (1.10.0)
|
59
62
|
escalate (0.3.0)
|
60
63
|
eventmachine (1.2.7)
|
61
|
-
globalid (0.
|
62
|
-
activesupport (>=
|
64
|
+
globalid (1.0.0)
|
65
|
+
activesupport (>= 5.0)
|
63
66
|
honeybadger (4.11.0)
|
64
|
-
i18n (1.
|
67
|
+
i18n (1.10.0)
|
65
68
|
concurrent-ruby (~> 1.0)
|
66
69
|
invoca-utils (0.4.1)
|
67
70
|
jaro_winkler (1.5.3)
|
68
71
|
json (2.6.1)
|
69
|
-
loofah (2.
|
72
|
+
loofah (2.15.0)
|
70
73
|
crass (~> 1.0.2)
|
71
74
|
nokogiri (>= 1.5.9)
|
72
75
|
mail (2.7.1)
|
73
76
|
mini_mime (>= 0.1.1)
|
74
77
|
method_source (0.9.2)
|
75
|
-
mini_mime (1.
|
76
|
-
mini_portile2 (2.
|
77
|
-
minitest (5.
|
78
|
-
|
79
|
-
|
78
|
+
mini_mime (1.1.2)
|
79
|
+
mini_portile2 (2.8.0)
|
80
|
+
minitest (5.15.0)
|
81
|
+
net-protocol (0.1.3)
|
82
|
+
timeout
|
83
|
+
net-smtp (0.3.1)
|
84
|
+
digest
|
85
|
+
net-protocol
|
86
|
+
timeout
|
87
|
+
nokogiri (1.13.3)
|
88
|
+
mini_portile2 (~> 2.8.0)
|
80
89
|
racc (~> 1.4)
|
81
90
|
parallel (1.17.0)
|
82
91
|
parser (2.6.3.0)
|
@@ -88,14 +97,15 @@ GEM
|
|
88
97
|
pry-byebug (3.8.0)
|
89
98
|
byebug (~> 11.0)
|
90
99
|
pry (~> 0.10)
|
91
|
-
|
100
|
+
psych (3.3.2)
|
101
|
+
racc (1.6.0)
|
92
102
|
rack (2.2.3)
|
93
103
|
rack-test (1.1.0)
|
94
104
|
rack (>= 1.0, < 3)
|
95
105
|
rails-dom-testing (2.0.3)
|
96
106
|
activesupport (>= 4.2.0)
|
97
107
|
nokogiri (>= 1.6)
|
98
|
-
rails-html-sanitizer (1.
|
108
|
+
rails-html-sanitizer (1.4.2)
|
99
109
|
loofah (~> 2.3)
|
100
110
|
rainbow (3.0.0)
|
101
111
|
rake (13.0.1)
|
@@ -111,7 +121,7 @@ GEM
|
|
111
121
|
rspec-mocks (3.9.1)
|
112
122
|
diff-lcs (>= 1.2.0, < 2.0)
|
113
123
|
rspec-support (~> 3.9.0)
|
114
|
-
rspec-support (3.9.
|
124
|
+
rspec-support (3.9.4)
|
115
125
|
rspec_junit_formatter (0.4.1)
|
116
126
|
rspec-core (>= 2, < 4, != 2.12.0)
|
117
127
|
rubocop (0.74.0)
|
@@ -126,10 +136,11 @@ GEM
|
|
126
136
|
power_assert
|
127
137
|
thor (1.0.1)
|
128
138
|
thread_safe (0.3.6)
|
139
|
+
timeout (0.2.0)
|
129
140
|
tzinfo (1.2.9)
|
130
141
|
thread_safe (~> 0.1)
|
131
142
|
unicode-display_width (1.6.0)
|
132
|
-
zeitwerk (2.4
|
143
|
+
zeitwerk (2.5.4)
|
133
144
|
|
134
145
|
PLATFORMS
|
135
146
|
ruby
|
@@ -149,4 +160,4 @@ DEPENDENCIES
|
|
149
160
|
test-unit
|
150
161
|
|
151
162
|
BUNDLED WITH
|
152
|
-
|
163
|
+
2.2.29
|
data/exception_handling.gemspec
CHANGED
@@ -20,11 +20,13 @@ Gem::Specification.new do |spec|
|
|
20
20
|
"allowed_push_host" => "https://rubygems.org"
|
21
21
|
}
|
22
22
|
|
23
|
-
spec.add_dependency 'actionmailer', '>=
|
24
|
-
spec.add_dependency 'actionpack', '>=
|
25
|
-
spec.add_dependency 'activesupport', '>=
|
26
|
-
spec.add_dependency 'contextual_logger', '~> 0
|
23
|
+
spec.add_dependency 'actionmailer', '>= 5.2', '< 7.0'
|
24
|
+
spec.add_dependency 'actionpack', '>= 5.2', '< 7.0'
|
25
|
+
spec.add_dependency 'activesupport', '>= 5.2', '< 7.0'
|
26
|
+
spec.add_dependency 'contextual_logger', '~> 1.0'
|
27
27
|
spec.add_dependency 'escalate', '~> 0.3'
|
28
28
|
spec.add_dependency 'eventmachine', '~> 1.0'
|
29
29
|
spec.add_dependency 'invoca-utils', '~> 0.3'
|
30
|
+
spec.add_dependency 'psych', '~> 3.0'
|
31
|
+
spec.add_dependency 'net-smtp'
|
30
32
|
end
|
data/gemfiles/rails_5.gemfile
CHANGED
data/gemfiles/rails_6.gemfile
CHANGED
data/lib/exception_handling.rb
CHANGED
@@ -230,9 +230,9 @@ module ExceptionHandling # never included
|
|
230
230
|
log_message = "#{exception_context}\n#{ex.class}: (#{encode_utf8(ex.message.to_s)}):\n " + clean_backtrace(ex).join("\n ") + "\n\n"
|
231
231
|
|
232
232
|
if ex.is_a?(Warning)
|
233
|
-
ExceptionHandling.logger.warn("\nExceptionHandlingWarning (Warning:#{timestamp}) #{log_message}", log_context)
|
233
|
+
ExceptionHandling.logger.warn("\nExceptionHandlingWarning (Warning:#{timestamp}) #{log_message}", **log_context)
|
234
234
|
else
|
235
|
-
ExceptionHandling.logger.fatal("\nExceptionHandlingError (Error:#{timestamp}) #{log_message}", log_context)
|
235
|
+
ExceptionHandling.logger.fatal("\nExceptionHandlingError (Error:#{timestamp}) #{log_message}", **log_context)
|
236
236
|
end
|
237
237
|
end
|
238
238
|
end
|
@@ -288,7 +288,7 @@ module ExceptionHandling # never included
|
|
288
288
|
#
|
289
289
|
# Expects passed in hash to only include keys which be directly set on the Honeybadger config
|
290
290
|
#
|
291
|
-
def enable_honeybadger(config
|
291
|
+
def enable_honeybadger(**config)
|
292
292
|
Bundler.require(:honeybadger)
|
293
293
|
Honeybadger.configure do |config_klass|
|
294
294
|
config.each do |k, v|
|
@@ -297,28 +297,28 @@ module ExceptionHandling # never included
|
|
297
297
|
end
|
298
298
|
end
|
299
299
|
|
300
|
-
def log_warning(message, log_context
|
300
|
+
def log_warning(message, **log_context)
|
301
301
|
warning = Warning.new(message)
|
302
302
|
warning.set_backtrace([])
|
303
303
|
log_error(warning, **log_context)
|
304
304
|
end
|
305
305
|
|
306
|
-
def log_info(message, log_context
|
307
|
-
ExceptionHandling.logger.info(message, log_context)
|
306
|
+
def log_info(message, **log_context)
|
307
|
+
ExceptionHandling.logger.info(message, **log_context)
|
308
308
|
end
|
309
309
|
|
310
|
-
def log_debug(message, log_context
|
311
|
-
ExceptionHandling.logger.debug(message, log_context)
|
310
|
+
def log_debug(message, **log_context)
|
311
|
+
ExceptionHandling.logger.debug(message, **log_context)
|
312
312
|
end
|
313
313
|
|
314
|
-
def ensure_safe(exception_context = "", log_context
|
314
|
+
def ensure_safe(exception_context = "", **log_context)
|
315
315
|
yield
|
316
316
|
rescue => ex
|
317
317
|
log_error(ex, exception_context, **log_context)
|
318
318
|
nil
|
319
319
|
end
|
320
320
|
|
321
|
-
def ensure_completely_safe(exception_context = "", log_context
|
321
|
+
def ensure_completely_safe(exception_context = "", **log_context)
|
322
322
|
yield
|
323
323
|
rescue SystemExit, SystemStackError, NoMemoryError, SecurityError, SignalException
|
324
324
|
raise
|
@@ -333,29 +333,29 @@ module ExceptionHandling # never included
|
|
333
333
|
escalate(email_subject, ex, last_exception_timestamp, production_support_recipients)
|
334
334
|
end
|
335
335
|
|
336
|
-
def escalate_error(exception_or_string, email_subject, custom_recipients = nil, log_context
|
336
|
+
def escalate_error(exception_or_string, email_subject, custom_recipients = nil, **log_context)
|
337
337
|
ex = make_exception(exception_or_string)
|
338
338
|
log_error(ex, **log_context)
|
339
339
|
escalate(email_subject, ex, last_exception_timestamp, custom_recipients)
|
340
340
|
end
|
341
341
|
|
342
|
-
def escalate_warning(message, email_subject, custom_recipients = nil, log_context
|
342
|
+
def escalate_warning(message, email_subject, custom_recipients = nil, **log_context)
|
343
343
|
ex = Warning.new(message)
|
344
344
|
log_error(ex, **log_context)
|
345
345
|
escalate(email_subject, ex, last_exception_timestamp, custom_recipients)
|
346
346
|
end
|
347
347
|
|
348
|
-
def ensure_escalation(email_subject, custom_recipients = nil, log_context
|
348
|
+
def ensure_escalation(email_subject, custom_recipients = nil, **log_context)
|
349
349
|
yield
|
350
350
|
rescue => ex
|
351
|
-
escalate_error(ex, email_subject, custom_recipients, log_context)
|
351
|
+
escalate_error(ex, email_subject, custom_recipients, **log_context)
|
352
352
|
nil
|
353
353
|
end
|
354
354
|
|
355
355
|
deprecate :escalate_to_production_support, :escalate_error, :escalate_warning, :ensure_escalation,
|
356
356
|
deprecator: ActiveSupport::Deprecation.new('3.0', 'ExceptionHandling')
|
357
357
|
|
358
|
-
def alert_warning(exception_or_string, alert_name, exception_context, log_context)
|
358
|
+
def alert_warning(exception_or_string, alert_name, exception_context, **log_context)
|
359
359
|
ex = make_exception(exception_or_string)
|
360
360
|
log_error(ex, exception_context, **log_context)
|
361
361
|
begin
|
@@ -365,10 +365,10 @@ module ExceptionHandling # never included
|
|
365
365
|
end
|
366
366
|
end
|
367
367
|
|
368
|
-
def ensure_alert(alert_name, exception_context, log_context
|
368
|
+
def ensure_alert(alert_name, exception_context, **log_context)
|
369
369
|
yield
|
370
370
|
rescue => ex
|
371
|
-
alert_warning(ex, alert_name, exception_context, log_context)
|
371
|
+
alert_warning(ex, alert_name, exception_context, **log_context)
|
372
372
|
nil
|
373
373
|
end
|
374
374
|
|
@@ -385,7 +385,7 @@ module ExceptionHandling # never included
|
|
385
385
|
result
|
386
386
|
end
|
387
387
|
|
388
|
-
def log_periodically(exception_key, interval, message, log_context
|
388
|
+
def log_periodically(exception_key, interval, message, **log_context)
|
389
389
|
self.periodic_exception_intervals ||= {}
|
390
390
|
last_logged = self.periodic_exception_intervals[exception_key]
|
391
391
|
if !last_logged || ((last_logged + interval) < Time.now)
|
@@ -15,6 +15,6 @@ module ExceptionHelpers
|
|
15
15
|
|
16
16
|
def capture_notifications
|
17
17
|
@sent_notifications = []
|
18
|
-
allow(ExceptionHandling).to receive(:send_exception_to_honeybadger).with(
|
18
|
+
allow(ExceptionHandling).to receive(:send_exception_to_honeybadger).with(any_args) { |exception_info| @sent_notifications << exception_info }
|
19
19
|
end
|
20
20
|
end
|
@@ -41,7 +41,7 @@ module ExceptionHandling
|
|
41
41
|
@exception_catalog = ExceptionCatalog.new(ExceptionHandling.filter_list_filename)
|
42
42
|
|
43
43
|
expect(ExceptionHandling).to receive(:log_error).never
|
44
|
-
expect(ExceptionHandling).to receive(:write_exception_to_log).with(anything, "ExceptionCatalog#refresh_filters: ./config/exception_filters.yml",
|
44
|
+
expect(ExceptionHandling).to receive(:write_exception_to_log).with(anything, "ExceptionCatalog#refresh_filters: ./config/exception_filters.yml", any_args)
|
45
45
|
expect(@exception_catalog).to receive(:load_file) { raise "noooooo" }
|
46
46
|
|
47
47
|
@exception_catalog.find({})
|
@@ -31,7 +31,7 @@ module ExceptionHandling
|
|
31
31
|
it "use the current_controller when available" do
|
32
32
|
capture_notifications
|
33
33
|
|
34
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/blah/,
|
34
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/blah/, any_args).at_least(:once)
|
35
35
|
@controller.simulate_around_filter do
|
36
36
|
ExceptionHandling.log_error(ArgumentError.new("blah"))
|
37
37
|
expect(sent_notifications.size).to eq(1)
|
@@ -109,8 +109,8 @@ describe ExceptionHandling do
|
|
109
109
|
|
110
110
|
context "with warn and honeybadger notify stubbed" do
|
111
111
|
before do
|
112
|
-
allow(ExceptionHandling).to receive(:warn).with(
|
113
|
-
allow(Honeybadger).to receive(:notify).with(
|
112
|
+
allow(ExceptionHandling).to receive(:warn).with(any_args)
|
113
|
+
allow(Honeybadger).to receive(:notify).with(any_args)
|
114
114
|
end
|
115
115
|
|
116
116
|
context "with logger stashed" do
|
@@ -158,7 +158,12 @@ describe ExceptionHandling do
|
|
158
158
|
|
159
159
|
context "#log_warning" do
|
160
160
|
it "have empty array as a backtrace" do
|
161
|
-
|
161
|
+
expected_args = if RUBY_VERSION < '2.7'
|
162
|
+
[ExceptionHandling::Warning, anything]
|
163
|
+
else
|
164
|
+
[ExceptionHandling::Warning]
|
165
|
+
end
|
166
|
+
expect(ExceptionHandling).to receive(:log_error).with(*expected_args) do |error|
|
162
167
|
expect(error.backtrace).to eq([])
|
163
168
|
end
|
164
169
|
ExceptionHandling.log_warning('Now with empty array as a backtrace!')
|
@@ -367,13 +372,13 @@ describe ExceptionHandling do
|
|
367
372
|
|
368
373
|
context "ExceptionHandling.ensure_safe" do
|
369
374
|
it "log an exception with call stack if an exception is raised." do
|
370
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/,
|
375
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
371
376
|
ExceptionHandling.ensure_safe { raise ArgumentError, "blah" }
|
372
377
|
end
|
373
378
|
|
374
379
|
if ActionView::VERSION::MAJOR >= 5
|
375
380
|
it "log an exception with call stack if an ActionView template exception is raised." do
|
376
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(Error:\d+\) \nActionView::Template::Error: \(blah\):\n /,
|
381
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(Error:\d+\) \nActionView::Template::Error: \(blah\):\n /, any_args)
|
377
382
|
ExceptionHandling.ensure_safe do
|
378
383
|
begin
|
379
384
|
# Rails 5 made the switch from ActionView::TemplateError taking in the original exception
|
@@ -386,7 +391,7 @@ describe ExceptionHandling do
|
|
386
391
|
end
|
387
392
|
else
|
388
393
|
it "log an exception with call stack if an ActionView template exception is raised." do
|
389
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(Error:\d+\) \nActionView::Template::Error: \(blah\):\n /,
|
394
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(Error:\d+\) \nActionView::Template::Error: \(blah\):\n /, any_args)
|
390
395
|
ExceptionHandling.ensure_safe { raise ActionView::TemplateError.new({}, ArgumentError.new("blah")) }
|
391
396
|
end
|
392
397
|
end
|
@@ -403,13 +408,13 @@ describe ExceptionHandling do
|
|
403
408
|
end
|
404
409
|
|
405
410
|
it "return nil if an exception is raised during an assignment" do
|
406
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/,
|
411
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
407
412
|
b = ExceptionHandling.ensure_safe { raise ArgumentError, "blah" }
|
408
413
|
expect(b).to be_nil
|
409
414
|
end
|
410
415
|
|
411
416
|
it "allow a message to be appended to the error when logged." do
|
412
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/mooo\nArgumentError: \(blah\):\n.*exception_handling_spec\.rb/,
|
417
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/mooo\nArgumentError: \(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
413
418
|
b = ExceptionHandling.ensure_safe("mooo") { raise ArgumentError, "blah" }
|
414
419
|
expect(b).to be_nil
|
415
420
|
end
|
@@ -417,7 +422,7 @@ describe ExceptionHandling do
|
|
417
422
|
it "only rescue StandardError and descendents" do
|
418
423
|
expect { ExceptionHandling.ensure_safe("mooo") { raise Exception } }.to raise_exception(Exception)
|
419
424
|
|
420
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/mooo\nStandardError: \(blah\):\n.*exception_handling_spec\.rb/,
|
425
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/mooo\nStandardError: \(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
421
426
|
|
422
427
|
b = ExceptionHandling.ensure_safe("mooo") { raise StandardError, "blah" }
|
423
428
|
expect(b).to be_nil
|
@@ -426,7 +431,7 @@ describe ExceptionHandling do
|
|
426
431
|
|
427
432
|
context "ExceptionHandling.ensure_completely_safe" do
|
428
433
|
it "log an exception if an exception is raised." do
|
429
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/,
|
434
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
430
435
|
ExceptionHandling.ensure_completely_safe { raise ArgumentError, "blah" }
|
431
436
|
end
|
432
437
|
|
@@ -442,19 +447,19 @@ describe ExceptionHandling do
|
|
442
447
|
end
|
443
448
|
|
444
449
|
it "return nil if an exception is raised during an assignment" do
|
445
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/,
|
450
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/, any_args) { nil }
|
446
451
|
b = ExceptionHandling.ensure_completely_safe { raise ArgumentError, "blah" }
|
447
452
|
expect(b).to be_nil
|
448
453
|
end
|
449
454
|
|
450
455
|
it "allow a message to be appended to the error when logged." do
|
451
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/mooo\nArgumentError: \(blah\):\n.*exception_handling_spec\.rb/,
|
456
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/mooo\nArgumentError: \(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
452
457
|
b = ExceptionHandling.ensure_completely_safe("mooo") { raise ArgumentError, "blah" }
|
453
458
|
expect(b).to be_nil
|
454
459
|
end
|
455
460
|
|
456
461
|
it "rescue any instance or child of Exception" do
|
457
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/,
|
462
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
458
463
|
ExceptionHandling.ensure_completely_safe { raise Exception, "blah" }
|
459
464
|
end
|
460
465
|
|
@@ -476,7 +481,7 @@ describe ExceptionHandling do
|
|
476
481
|
end
|
477
482
|
|
478
483
|
it "log the exception as usual and send the proper email" do
|
479
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/,
|
484
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
480
485
|
ExceptionHandling.ensure_escalation("Favorite Feature") { raise ArgumentError, "blah" }
|
481
486
|
expect(ActionMailer::Base.deliveries.count).to eq(1)
|
482
487
|
expect(sent_notifications.size).to eq(1), sent_notifications.inspect
|
@@ -511,7 +516,7 @@ describe ExceptionHandling do
|
|
511
516
|
|
512
517
|
it "allow the caller to specify custom recipients" do
|
513
518
|
custom_recipients = ['something@invoca.com']
|
514
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/,
|
519
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
515
520
|
ExceptionHandling.ensure_escalation("Favorite Feature", custom_recipients) { raise ArgumentError, "blah" }
|
516
521
|
expect(ActionMailer::Base.deliveries.count).to eq(1)
|
517
522
|
expect(sent_notifications.size).to eq(1), sent_notifications.inspect
|
@@ -527,7 +532,7 @@ describe ExceptionHandling do
|
|
527
532
|
context "ExceptionHandling.ensure_alert" do
|
528
533
|
it "log the exception as usual and fire a sensu event" do
|
529
534
|
expect(ExceptionHandling::Sensu).to receive(:generate_event).with("Favorite Feature", "test context\nblah")
|
530
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/,
|
535
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
531
536
|
ExceptionHandling.ensure_alert('Favorite Feature', 'test context') { raise ArgumentError, "blah" }
|
532
537
|
end
|
533
538
|
|
@@ -539,8 +544,8 @@ describe ExceptionHandling do
|
|
539
544
|
|
540
545
|
it "log if the sensu event could not be sent" do
|
541
546
|
expect(ExceptionHandling::Sensu).to receive(:send_event).with(anything) { raise "Failed to send" }
|
542
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/first_test_exception/,
|
543
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/Failed to send/,
|
547
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/first_test_exception/, any_args)
|
548
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/Failed to send/, any_args)
|
544
549
|
ExceptionHandling.ensure_alert("Not Used", 'test context') { raise ArgumentError, "first_test_exception" }
|
545
550
|
end
|
546
551
|
|
@@ -570,7 +575,7 @@ describe ExceptionHandling do
|
|
570
575
|
it "include the timestamp when the exception is logged" do
|
571
576
|
capture_notifications
|
572
577
|
|
573
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(Error:517033020\) context\nArgumentError: \(blah\):\n.*exception_handling_spec\.rb/,
|
578
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/\(Error:517033020\) context\nArgumentError: \(blah\):\n.*exception_handling_spec\.rb/, any_args)
|
574
579
|
b = ExceptionHandling.ensure_safe("context") { raise ArgumentError, "blah" }
|
575
580
|
expect(b).to be_nil
|
576
581
|
|
@@ -845,7 +850,7 @@ describe ExceptionHandling do
|
|
845
850
|
allow(ExceptionHandling).to receive(:make_exception) { raise ArgumentError, "Bad argument" }
|
846
851
|
expect(ExceptionHandling).to receive(:write_exception_to_log).with(satisfy { |ex| ex.to_s['Bad argument'] },
|
847
852
|
satisfy { |context| context['ExceptionHandlingError: log_error rescued exception while logging Runtime message'] },
|
848
|
-
|
853
|
+
any_args)
|
849
854
|
ExceptionHandling.log_error(RuntimeError.new("A runtime error"), "Runtime message")
|
850
855
|
end
|
851
856
|
|
@@ -853,7 +858,7 @@ describe ExceptionHandling do
|
|
853
858
|
expect(ExceptionHandling).to receive(:write_exception_to_log).with(satisfy { |ex| ex.to_s['Bad argument'] },
|
854
859
|
satisfy { |context| context['Context message'] },
|
855
860
|
anything,
|
856
|
-
|
861
|
+
any_args)
|
857
862
|
ExceptionHandling.log_error(ArgumentError.new("Bad argument"), "Context message") { |_data| raise 'Error!!!' }
|
858
863
|
end
|
859
864
|
|
@@ -958,7 +963,7 @@ describe ExceptionHandling do
|
|
958
963
|
it "omit environment defaults" do
|
959
964
|
capture_notifications
|
960
965
|
|
961
|
-
allow(ExceptionHandling).to receive(:send_exception_to_honeybadger).with(
|
966
|
+
allow(ExceptionHandling).to receive(:send_exception_to_honeybadger).with(any_args) { |exception_info| sent_notifications << exception_info }
|
962
967
|
|
963
968
|
ExceptionHandling.log_error("some message") do |data|
|
964
969
|
data[:environment] = { SERVER_PORT: '80', SERVER_PROTOCOL: "HTTP/1.0" }
|
@@ -1047,7 +1052,7 @@ describe ExceptionHandling do
|
|
1047
1052
|
ActionMailer::Base.deliveries.clear
|
1048
1053
|
|
1049
1054
|
set_test_const('EventMachine::Protocols::SmtpClient', SmtpClientErrbackStub)
|
1050
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/Exception to escalate/,
|
1055
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/Exception to escalate/, any_args)
|
1051
1056
|
expect(ExceptionHandling.logger).to receive(:fatal).with(/Failed to email by SMTP: "credential mismatch"/)
|
1052
1057
|
|
1053
1058
|
ExceptionHandling.ensure_escalation("ensure message") { raise 'Exception to escalate!' }
|
@@ -1059,7 +1064,7 @@ describe ExceptionHandling do
|
|
1059
1064
|
expect((SmtpClientErrbackStub.send_hash & EXPECTED_SMTP_HASH.keys).map_hash { |_k, v| v.to_s }).to eq(EXPECTED_SMTP_HASH), SmtpClientErrbackStub.send_hash.inspect end
|
1060
1065
|
|
1061
1066
|
it "log fatal on EventMachine dns resolver errback" do
|
1062
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/Exception to escalate/,
|
1067
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/Exception to escalate/, any_args)
|
1063
1068
|
expect(ExceptionHandling.logger).to receive(:fatal).with(/Failed to resolv DNS for localhost: "softlayer sucks"/)
|
1064
1069
|
|
1065
1070
|
ExceptionHandling.ensure_escalation("ensure message") { raise 'Exception to escalate!' }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_handling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '7.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '5.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '7.0'
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '5.2'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '7.0'
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '5.2'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '7.0'
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '
|
59
|
+
version: '5.2'
|
60
60
|
- - "<"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '7.0'
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '5.2'
|
70
70
|
- - "<"
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '7.0'
|
@@ -76,14 +76,14 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: '0
|
79
|
+
version: '1.0'
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '0
|
86
|
+
version: '1.0'
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: escalate
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,6 +126,34 @@ dependencies:
|
|
126
126
|
- - "~>"
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0.3'
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: psych
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - "~>"
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '3.0'
|
136
|
+
type: :runtime
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - "~>"
|
141
|
+
- !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'
|
129
157
|
description: Exception handling logger/emailer
|
130
158
|
email:
|
131
159
|
- development@invoca.com
|
@@ -147,7 +175,6 @@ files:
|
|
147
175
|
- Rakefile
|
148
176
|
- config/exception_filters.yml
|
149
177
|
- exception_handling.gemspec
|
150
|
-
- gemfiles/rails_4.gemfile
|
151
178
|
- gemfiles/rails_5.gemfile
|
152
179
|
- gemfiles/rails_6.gemfile
|
153
180
|
- lib/exception_handling.rb
|
@@ -199,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
226
|
- !ruby/object:Gem::Version
|
200
227
|
version: '0'
|
201
228
|
requirements: []
|
202
|
-
rubygems_version: 3.
|
229
|
+
rubygems_version: 3.1.6
|
203
230
|
signing_key:
|
204
231
|
specification_version: 4
|
205
232
|
summary: Invoca's exception handling logger/emailer layer, based on exception_notifier.
|
data/gemfiles/rails_4.gemfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "actionmailer", "~> 4.2"
|
6
|
-
gem "activesupport", "~> 4.2"
|
7
|
-
gem "appraisal", "~> 2.2"
|
8
|
-
gem "honeybadger"
|
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", "~> 4.2"
|
17
|
-
|
18
|
-
gemspec path: "../"
|