exception_handling 2.4.0.pre.1 → 2.4.0.pre.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/Gemfile.lock +2 -2
- data/exception_handling.gemspec +3 -3
- data/lib/exception_handling/version.rb +1 -1
- data/lib/exception_handling.rb +5 -2
- data/test/unit/exception_handling_test.rb +5 -16
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d72ddea7583184b3af78066a245bc9ce33f7e2a4
|
4
|
+
data.tar.gz: 2adff23accc14952a2c4b3174e5796326815df3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9563434560717302dff8633c83a7acc77c72d735a677d24e8409d9ec77997c43d267837f4565fce13290b999ee1e6a571aae6642f568109b73452e9df1137ac6
|
7
|
+
data.tar.gz: f2b64b4d2fdf615a6d55c7897c17f1cf1f129802c6e173a938a7f589be396caa6d640ef5eac89f3f085019d0e40fe7f1f012f00d96ed957a151a6d0dfca55fa5
|
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ GIT
|
|
8
8
|
PATH
|
9
9
|
remote: .
|
10
10
|
specs:
|
11
|
-
exception_handling (2.4.0.pre.
|
11
|
+
exception_handling (2.4.0.pre.2)
|
12
12
|
actionmailer (~> 4.2)
|
13
13
|
actionpack (~> 4.2)
|
14
14
|
activesupport (~> 4.2)
|
@@ -164,4 +164,4 @@ DEPENDENCIES
|
|
164
164
|
shoulda (> 3.1.1)
|
165
165
|
|
166
166
|
BUNDLED WITH
|
167
|
-
1.17.
|
167
|
+
1.17.3
|
data/exception_handling.gemspec
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
require File.expand_path('lib/exception_handling/version', __dir__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.authors = ["
|
7
|
-
spec.email = ["
|
6
|
+
spec.authors = ["Invoca"]
|
7
|
+
spec.email = ["development@invoca.com"]
|
8
8
|
spec.description = 'Exception handling logger/emailer'
|
9
9
|
spec.summary = "Invoca's exception handling logger/emailer layer, based on exception_notifier. Works with Rails or EventMachine or EventMachine+Synchrony."
|
10
10
|
spec.homepage = "https://github.com/Invoca/exception_handling"
|
11
11
|
|
12
|
-
spec.files = `git ls-files`.split(
|
12
|
+
spec.files = `git ls-files`.split("\n")
|
13
13
|
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
14
14
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/.*\.rb})
|
15
15
|
spec.name = "exception_handling"
|
data/lib/exception_handling.rb
CHANGED
@@ -177,13 +177,16 @@ module ExceptionHandling # never included
|
|
177
177
|
# Called directly by our code, usually from rescue blocks.
|
178
178
|
# Writes to log file and may send to honeybadger
|
179
179
|
#
|
180
|
+
# TODO: the **log_context means we can never have context named treat_like_warning. In general, keyword args will be conflated with log_context.
|
181
|
+
# Ideally we'd separate to log_context from the other keywords so they don't interfere in any way. Or have no keyword args.
|
182
|
+
#
|
180
183
|
# Functional Test Operation:
|
181
184
|
# Calls into handle_stub_log_error and returns. no log file. no honeybadger
|
182
185
|
#
|
183
|
-
def log_error(exception_or_string, exception_context = '', treat_like_warning: false, **log_context, &data_callback)
|
186
|
+
def log_error(exception_or_string, exception_context = '', controller = nil, treat_like_warning: false, **log_context, &data_callback)
|
184
187
|
ex = make_exception(exception_or_string)
|
185
188
|
timestamp = set_log_error_timestamp
|
186
|
-
exception_info = ExceptionInfo.new(ex, exception_context, timestamp, current_controller, data_callback)
|
189
|
+
exception_info = ExceptionInfo.new(ex, exception_context, timestamp, controller || current_controller, data_callback)
|
187
190
|
|
188
191
|
if stub_handler
|
189
192
|
stub_handler.handle_stub_log_error(exception_info.data)
|
@@ -110,14 +110,7 @@ class ExceptionHandlingTest < ActiveSupport::TestCase
|
|
110
110
|
end
|
111
111
|
|
112
112
|
context "#log_error" do
|
113
|
-
should "take in additional
|
114
|
-
ExceptionHandling.log_error('This is an Error', 'This is the prefix context', service_name: 'exception_handling')
|
115
|
-
assert_match(/This is an Error/, logged_excluding_reload_filter.last[:message])
|
116
|
-
assert_not_empty logged_excluding_reload_filter.last[:context]
|
117
|
-
assert_equal({ service_name: 'exception_handling' }, logged_excluding_reload_filter.last[:context])
|
118
|
-
end
|
119
|
-
|
120
|
-
should "take in additional keyword args as logging context and pass them to the logger (using **)" do
|
113
|
+
should "take in additional logging context hash and pass it to the logger" do
|
121
114
|
ExceptionHandling.log_error('This is an Error', 'This is the prefix context', service_name: 'exception_handling')
|
122
115
|
assert_match(/This is an Error/, logged_excluding_reload_filter.last[:message])
|
123
116
|
assert_not_empty logged_excluding_reload_filter.last[:context]
|
@@ -431,8 +424,8 @@ class ExceptionHandlingTest < ActiveSupport::TestCase
|
|
431
424
|
|
432
425
|
ExceptionHandling.ensure_escalation("ensure context") { raise ArgumentError, "first_test_exception" }
|
433
426
|
|
434
|
-
assert_match
|
435
|
-
assert_match
|
427
|
+
assert_match(/ArgumentError.*first_test_exception/, log_fatals[0].first)
|
428
|
+
assert_match(/safe_email_deliver.*Delivery Error/, log_fatals[1].first)
|
436
429
|
|
437
430
|
assert_equal 2, log_fatals.size, log_fatals.inspect
|
438
431
|
|
@@ -550,10 +543,6 @@ class ExceptionHandlingTest < ActiveSupport::TestCase
|
|
550
543
|
end
|
551
544
|
|
552
545
|
context "with Honeybadger defined" do
|
553
|
-
teardown do
|
554
|
-
ExceptionHandling.current_controller = nil
|
555
|
-
end
|
556
|
-
|
557
546
|
should "not send_exception_to_honeybadger when log_warning is executed" do
|
558
547
|
dont_allow(ExceptionHandling).send_exception_to_honeybadger
|
559
548
|
ExceptionHandling.log_warning("This should not go to honeybadger")
|
@@ -592,7 +581,7 @@ class ExceptionHandlingTest < ActiveSupport::TestCase
|
|
592
581
|
parameters = { advertiser_id: 435, controller: "some_controller" }
|
593
582
|
session = { username: "jsmith" }
|
594
583
|
request_uri = "host/path"
|
595
|
-
|
584
|
+
controller = create_dummy_controller(env, parameters, session, request_uri)
|
596
585
|
stub(ExceptionHandling).server_name { "invoca_fe98" }
|
597
586
|
|
598
587
|
exception = StandardError.new("Some Exception")
|
@@ -606,7 +595,7 @@ class ExceptionHandlingTest < ActiveSupport::TestCase
|
|
606
595
|
mock(Honeybadger).notify.with_any_args do |data|
|
607
596
|
honeybadger_data = data
|
608
597
|
end
|
609
|
-
ExceptionHandling.log_error(exception, exception_context) do |data|
|
598
|
+
ExceptionHandling.log_error(exception, exception_context, controller) do |data|
|
610
599
|
data[:scm_revision] = "5b24eac37aaa91f5784901e9aabcead36fd9df82"
|
611
600
|
data[:user_details] = { username: "jsmith" }
|
612
601
|
data[:event_response] = "Event successfully received"
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_handling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.0.pre.
|
4
|
+
version: 2.4.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Invoca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
version: '0.0'
|
111
111
|
description: Exception handling logger/emailer
|
112
112
|
email:
|
113
|
-
-
|
113
|
+
- development@invoca.com
|
114
114
|
executables: []
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|