exception_handling 2.11.1 → 2.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +3 -3
- data/lib/exception_handling/version.rb +1 -1
- data/lib/exception_handling.rb +4 -4
- 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 +23 -23
- metadata +1 -1
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
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ 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
|
+
|
7
11
|
## [2.11.1] - 2022-04-04
|
8
12
|
### Fixed
|
9
13
|
- Fixed bug in ruby 3+ where `contextual_logger` was missing ruby 3+ support
|
@@ -83,6 +87,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
83
87
|
### Changed
|
84
88
|
- No longer depends on hobo_support. Uses invoca-utils 0.3 instead.
|
85
89
|
|
90
|
+
[2.11.2]: https://github.com/Invoca/exception_handling/compare/v2.11.1...v2.11.2
|
86
91
|
[2.11.1]: https://github.com/Invoca/exception_handling/compare/v2.11.0...v2.11.1
|
87
92
|
[2.11.0]: https://github.com/Invoca/exception_handling/compare/v2.10.0...v2.11.0
|
88
93
|
[2.10.0]: https://github.com/Invoca/exception_handling/compare/v2.9.0...v2.10.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
exception_handling (2.11.
|
4
|
+
exception_handling (2.11.2)
|
5
5
|
actionmailer (>= 5.2, < 7.0)
|
6
6
|
actionpack (>= 5.2, < 7.0)
|
7
7
|
activesupport (>= 5.2, < 7.0)
|
@@ -56,7 +56,7 @@ GEM
|
|
56
56
|
activesupport
|
57
57
|
json
|
58
58
|
crass (1.0.6)
|
59
|
-
diff-lcs (1.
|
59
|
+
diff-lcs (1.5.0)
|
60
60
|
digest (3.1.0)
|
61
61
|
erubi (1.10.0)
|
62
62
|
escalate (0.3.0)
|
@@ -121,7 +121,7 @@ GEM
|
|
121
121
|
rspec-mocks (3.9.1)
|
122
122
|
diff-lcs (>= 1.2.0, < 2.0)
|
123
123
|
rspec-support (~> 3.9.0)
|
124
|
-
rspec-support (3.9.
|
124
|
+
rspec-support (3.9.4)
|
125
125
|
rspec_junit_formatter (0.4.1)
|
126
126
|
rspec-core (>= 2, < 4, != 2.12.0)
|
127
127
|
rubocop (0.74.0)
|
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
|
@@ -304,11 +304,11 @@ module ExceptionHandling # never included
|
|
304
304
|
end
|
305
305
|
|
306
306
|
def log_info(message, **log_context)
|
307
|
-
ExceptionHandling.logger.info(message, log_context)
|
307
|
+
ExceptionHandling.logger.info(message, **log_context)
|
308
308
|
end
|
309
309
|
|
310
310
|
def log_debug(message, **log_context)
|
311
|
-
ExceptionHandling.logger.debug(message, log_context)
|
311
|
+
ExceptionHandling.logger.debug(message, **log_context)
|
312
312
|
end
|
313
313
|
|
314
314
|
def ensure_safe(exception_context = "", **log_context)
|
@@ -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
|
@@ -372,13 +372,13 @@ describe ExceptionHandling do
|
|
372
372
|
|
373
373
|
context "ExceptionHandling.ensure_safe" do
|
374
374
|
it "log an exception with call stack if an exception is raised." do
|
375
|
-
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)
|
376
376
|
ExceptionHandling.ensure_safe { raise ArgumentError, "blah" }
|
377
377
|
end
|
378
378
|
|
379
379
|
if ActionView::VERSION::MAJOR >= 5
|
380
380
|
it "log an exception with call stack if an ActionView template exception is raised." do
|
381
|
-
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)
|
382
382
|
ExceptionHandling.ensure_safe do
|
383
383
|
begin
|
384
384
|
# Rails 5 made the switch from ActionView::TemplateError taking in the original exception
|
@@ -391,7 +391,7 @@ describe ExceptionHandling do
|
|
391
391
|
end
|
392
392
|
else
|
393
393
|
it "log an exception with call stack if an ActionView template exception is raised." do
|
394
|
-
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)
|
395
395
|
ExceptionHandling.ensure_safe { raise ActionView::TemplateError.new({}, ArgumentError.new("blah")) }
|
396
396
|
end
|
397
397
|
end
|
@@ -408,13 +408,13 @@ describe ExceptionHandling do
|
|
408
408
|
end
|
409
409
|
|
410
410
|
it "return nil if an exception is raised during an assignment" do
|
411
|
-
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)
|
412
412
|
b = ExceptionHandling.ensure_safe { raise ArgumentError, "blah" }
|
413
413
|
expect(b).to be_nil
|
414
414
|
end
|
415
415
|
|
416
416
|
it "allow a message to be appended to the error when logged." do
|
417
|
-
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)
|
418
418
|
b = ExceptionHandling.ensure_safe("mooo") { raise ArgumentError, "blah" }
|
419
419
|
expect(b).to be_nil
|
420
420
|
end
|
@@ -422,7 +422,7 @@ describe ExceptionHandling do
|
|
422
422
|
it "only rescue StandardError and descendents" do
|
423
423
|
expect { ExceptionHandling.ensure_safe("mooo") { raise Exception } }.to raise_exception(Exception)
|
424
424
|
|
425
|
-
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)
|
426
426
|
|
427
427
|
b = ExceptionHandling.ensure_safe("mooo") { raise StandardError, "blah" }
|
428
428
|
expect(b).to be_nil
|
@@ -431,7 +431,7 @@ describe ExceptionHandling do
|
|
431
431
|
|
432
432
|
context "ExceptionHandling.ensure_completely_safe" do
|
433
433
|
it "log an exception if an exception is raised." do
|
434
|
-
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)
|
435
435
|
ExceptionHandling.ensure_completely_safe { raise ArgumentError, "blah" }
|
436
436
|
end
|
437
437
|
|
@@ -447,19 +447,19 @@ describe ExceptionHandling do
|
|
447
447
|
end
|
448
448
|
|
449
449
|
it "return nil if an exception is raised during an assignment" do
|
450
|
-
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 }
|
451
451
|
b = ExceptionHandling.ensure_completely_safe { raise ArgumentError, "blah" }
|
452
452
|
expect(b).to be_nil
|
453
453
|
end
|
454
454
|
|
455
455
|
it "allow a message to be appended to the error when logged." do
|
456
|
-
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)
|
457
457
|
b = ExceptionHandling.ensure_completely_safe("mooo") { raise ArgumentError, "blah" }
|
458
458
|
expect(b).to be_nil
|
459
459
|
end
|
460
460
|
|
461
461
|
it "rescue any instance or child of Exception" do
|
462
|
-
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)
|
463
463
|
ExceptionHandling.ensure_completely_safe { raise Exception, "blah" }
|
464
464
|
end
|
465
465
|
|
@@ -481,7 +481,7 @@ describe ExceptionHandling do
|
|
481
481
|
end
|
482
482
|
|
483
483
|
it "log the exception as usual and send the proper email" do
|
484
|
-
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)
|
485
485
|
ExceptionHandling.ensure_escalation("Favorite Feature") { raise ArgumentError, "blah" }
|
486
486
|
expect(ActionMailer::Base.deliveries.count).to eq(1)
|
487
487
|
expect(sent_notifications.size).to eq(1), sent_notifications.inspect
|
@@ -516,7 +516,7 @@ describe ExceptionHandling do
|
|
516
516
|
|
517
517
|
it "allow the caller to specify custom recipients" do
|
518
518
|
custom_recipients = ['something@invoca.com']
|
519
|
-
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)
|
520
520
|
ExceptionHandling.ensure_escalation("Favorite Feature", custom_recipients) { raise ArgumentError, "blah" }
|
521
521
|
expect(ActionMailer::Base.deliveries.count).to eq(1)
|
522
522
|
expect(sent_notifications.size).to eq(1), sent_notifications.inspect
|
@@ -532,7 +532,7 @@ describe ExceptionHandling do
|
|
532
532
|
context "ExceptionHandling.ensure_alert" do
|
533
533
|
it "log the exception as usual and fire a sensu event" do
|
534
534
|
expect(ExceptionHandling::Sensu).to receive(:generate_event).with("Favorite Feature", "test context\nblah")
|
535
|
-
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)
|
536
536
|
ExceptionHandling.ensure_alert('Favorite Feature', 'test context') { raise ArgumentError, "blah" }
|
537
537
|
end
|
538
538
|
|
@@ -544,8 +544,8 @@ describe ExceptionHandling do
|
|
544
544
|
|
545
545
|
it "log if the sensu event could not be sent" do
|
546
546
|
expect(ExceptionHandling::Sensu).to receive(:send_event).with(anything) { raise "Failed to send" }
|
547
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/first_test_exception/,
|
548
|
-
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)
|
549
549
|
ExceptionHandling.ensure_alert("Not Used", 'test context') { raise ArgumentError, "first_test_exception" }
|
550
550
|
end
|
551
551
|
|
@@ -575,7 +575,7 @@ describe ExceptionHandling do
|
|
575
575
|
it "include the timestamp when the exception is logged" do
|
576
576
|
capture_notifications
|
577
577
|
|
578
|
-
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)
|
579
579
|
b = ExceptionHandling.ensure_safe("context") { raise ArgumentError, "blah" }
|
580
580
|
expect(b).to be_nil
|
581
581
|
|
@@ -850,7 +850,7 @@ describe ExceptionHandling do
|
|
850
850
|
allow(ExceptionHandling).to receive(:make_exception) { raise ArgumentError, "Bad argument" }
|
851
851
|
expect(ExceptionHandling).to receive(:write_exception_to_log).with(satisfy { |ex| ex.to_s['Bad argument'] },
|
852
852
|
satisfy { |context| context['ExceptionHandlingError: log_error rescued exception while logging Runtime message'] },
|
853
|
-
|
853
|
+
any_args)
|
854
854
|
ExceptionHandling.log_error(RuntimeError.new("A runtime error"), "Runtime message")
|
855
855
|
end
|
856
856
|
|
@@ -858,7 +858,7 @@ describe ExceptionHandling do
|
|
858
858
|
expect(ExceptionHandling).to receive(:write_exception_to_log).with(satisfy { |ex| ex.to_s['Bad argument'] },
|
859
859
|
satisfy { |context| context['Context message'] },
|
860
860
|
anything,
|
861
|
-
|
861
|
+
any_args)
|
862
862
|
ExceptionHandling.log_error(ArgumentError.new("Bad argument"), "Context message") { |_data| raise 'Error!!!' }
|
863
863
|
end
|
864
864
|
|
@@ -963,7 +963,7 @@ describe ExceptionHandling do
|
|
963
963
|
it "omit environment defaults" do
|
964
964
|
capture_notifications
|
965
965
|
|
966
|
-
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 }
|
967
967
|
|
968
968
|
ExceptionHandling.log_error("some message") do |data|
|
969
969
|
data[:environment] = { SERVER_PORT: '80', SERVER_PROTOCOL: "HTTP/1.0" }
|
@@ -1052,7 +1052,7 @@ describe ExceptionHandling do
|
|
1052
1052
|
ActionMailer::Base.deliveries.clear
|
1053
1053
|
|
1054
1054
|
set_test_const('EventMachine::Protocols::SmtpClient', SmtpClientErrbackStub)
|
1055
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/Exception to escalate/,
|
1055
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/Exception to escalate/, any_args)
|
1056
1056
|
expect(ExceptionHandling.logger).to receive(:fatal).with(/Failed to email by SMTP: "credential mismatch"/)
|
1057
1057
|
|
1058
1058
|
ExceptionHandling.ensure_escalation("ensure message") { raise 'Exception to escalate!' }
|
@@ -1064,7 +1064,7 @@ describe ExceptionHandling do
|
|
1064
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
|
1065
1065
|
|
1066
1066
|
it "log fatal on EventMachine dns resolver errback" do
|
1067
|
-
expect(ExceptionHandling.logger).to receive(:fatal).with(/Exception to escalate/,
|
1067
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/Exception to escalate/, any_args)
|
1068
1068
|
expect(ExceptionHandling.logger).to receive(:fatal).with(/Failed to resolv DNS for localhost: "softlayer sucks"/)
|
1069
1069
|
|
1070
1070
|
ExceptionHandling.ensure_escalation("ensure message") { raise 'Exception to escalate!' }
|