exception_handling 2.13.0 → 3.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -3
- data/.ruby-version +1 -1
- data/Gemfile +16 -16
- data/Gemfile.lock +114 -110
- data/README.md +3 -7
- data/Rakefile +11 -8
- data/exception_handling.gemspec +10 -12
- data/lib/exception_handling/exception_info.rb +10 -13
- data/lib/exception_handling/honeybadger_callbacks.rb +59 -0
- data/lib/exception_handling/log_stub_error.rb +1 -2
- data/lib/exception_handling/methods.rb +53 -6
- data/lib/exception_handling/testing.rb +10 -20
- data/lib/exception_handling/version.rb +1 -1
- data/lib/exception_handling.rb +33 -68
- data/semaphore_ci/setup.sh +3 -0
- data/{spec → test}/helpers/controller_helpers.rb +0 -0
- data/{spec → test}/helpers/exception_helpers.rb +2 -2
- data/{spec/spec_helper.rb → test/test_helper.rb} +42 -63
- data/test/unit/exception_handling/exception_catalog_test.rb +85 -0
- data/test/unit/exception_handling/exception_description_test.rb +82 -0
- data/{spec/unit/exception_handling/exception_info_spec.rb → test/unit/exception_handling/exception_info_test.rb} +114 -153
- data/test/unit/exception_handling/honeybadger_callbacks_test.rb +122 -0
- data/{spec/unit/exception_handling/log_error_stub_spec.rb → test/unit/exception_handling/log_error_stub_test.rb} +22 -38
- data/{spec/unit/exception_handling/mailer_spec.rb → test/unit/exception_handling/mailer_test.rb} +18 -17
- data/test/unit/exception_handling/methods_test.rb +84 -0
- data/test/unit/exception_handling/sensu_test.rb +52 -0
- data/test/unit/exception_handling_test.rb +1109 -0
- metadata +60 -115
- data/.github/workflows/pipeline.yml +0 -33
- data/.rspec +0 -3
- data/Appraisals +0 -13
- data/CHANGELOG.md +0 -119
- data/gemfiles/rails_5.gemfile +0 -18
- data/gemfiles/rails_6.gemfile +0 -18
- data/lib/exception_handling/escalate_callback.rb +0 -19
- data/lib/exception_handling/logging_methods.rb +0 -27
- data/spec/rake_test_warning_false.rb +0 -20
- data/spec/unit/exception_handling/escalate_callback_spec.rb +0 -81
- data/spec/unit/exception_handling/exception_catalog_spec.rb +0 -85
- data/spec/unit/exception_handling/exception_description_spec.rb +0 -82
- data/spec/unit/exception_handling/logging_methods_spec.rb +0 -38
- data/spec/unit/exception_handling/methods_spec.rb +0 -105
- data/spec/unit/exception_handling/sensu_spec.rb +0 -51
- data/spec/unit/exception_handling_spec.rb +0 -1303
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6aee76b81d1d4742150afdeb95f8a6f544671a3f
|
4
|
+
data.tar.gz: 4822461573c54709a2d977b82e47de35cecfa51e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de1c0ab7cb7e7a493ce5f8c8d155ad98450edc891636e2d8e9d82ec2d8bdc312b45ba96f5902e0bc2d70adb35c0e4e20317bbea7d72d54625d7c2764ac2fb374
|
7
|
+
data.tar.gz: 7546dd2be9a2701d360cdd5fee3ea0e93b9a26e0072c835940659d5244c0e625743924cdde737fee08a7d5f909d03df1752b8e9ae6b8a7d354b62a77d8b89a57
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.2
|
data/Gemfile
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
|
6
|
-
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
7
|
-
"https://github.com/#{repo_name}.git"
|
8
|
-
end
|
9
|
-
|
5
|
+
# Specify your gem's dependencies in attr_default.gemspec
|
10
6
|
gemspec
|
11
7
|
|
12
|
-
gem 'actionmailer',
|
13
|
-
gem '
|
14
|
-
gem '
|
15
|
-
|
16
|
-
|
17
|
-
gem 'pry
|
18
|
-
gem 'rake'
|
19
|
-
gem '
|
20
|
-
gem '
|
21
|
-
gem '
|
22
|
-
|
8
|
+
gem 'actionmailer', '>= 4.2.11.1'
|
9
|
+
gem 'actionpack', '>= 4.2.11.1'
|
10
|
+
gem 'activesupport', '>= 4.2.11.1'
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem 'pry'
|
14
|
+
gem 'rake', '>=0.9'
|
15
|
+
gem 'rr'
|
16
|
+
gem 'rubocop'
|
17
|
+
gem 'shoulda', '> 3.1.1'
|
18
|
+
end
|
19
|
+
|
20
|
+
group :test do
|
21
|
+
gem 'honeybadger', '3.3.1-1', git: 'git@github.com:Invoca/honeybadger-ruby', ref: 'bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6'
|
22
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,129 +1,126 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git@github.com:Invoca/honeybadger-ruby
|
3
|
+
revision: bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6
|
4
|
+
ref: bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6
|
5
|
+
specs:
|
6
|
+
honeybadger (3.3.1.pre.1)
|
7
|
+
|
1
8
|
PATH
|
2
9
|
remote: .
|
3
10
|
specs:
|
4
|
-
exception_handling (
|
5
|
-
actionmailer (
|
6
|
-
actionpack (
|
7
|
-
activesupport (
|
8
|
-
contextual_logger
|
9
|
-
escalate (~> 0.3)
|
11
|
+
exception_handling (3.0.pre.1)
|
12
|
+
actionmailer (~> 4.2)
|
13
|
+
actionpack (~> 4.2)
|
14
|
+
activesupport (~> 4.2)
|
15
|
+
contextual_logger
|
10
16
|
eventmachine (~> 1.0)
|
11
|
-
|
12
|
-
|
13
|
-
psych (~> 3.0)
|
17
|
+
hobo_support
|
18
|
+
invoca-utils (~> 0.0)
|
14
19
|
|
15
20
|
GEM
|
16
21
|
remote: https://rubygems.org/
|
17
22
|
specs:
|
18
|
-
actionmailer (
|
19
|
-
actionpack (=
|
20
|
-
actionview (=
|
21
|
-
activejob (=
|
23
|
+
actionmailer (4.2.11.1)
|
24
|
+
actionpack (= 4.2.11.1)
|
25
|
+
actionview (= 4.2.11.1)
|
26
|
+
activejob (= 4.2.11.1)
|
22
27
|
mail (~> 2.5, >= 2.5.4)
|
23
|
-
rails-dom-testing (~>
|
24
|
-
actionpack (
|
25
|
-
actionview (=
|
26
|
-
activesupport (=
|
27
|
-
rack (~>
|
28
|
-
rack-test (
|
29
|
-
rails-dom-testing (~>
|
30
|
-
rails-html-sanitizer (~> 1.0, >= 1.2
|
31
|
-
actionview (
|
32
|
-
activesupport (=
|
28
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
29
|
+
actionpack (4.2.11.1)
|
30
|
+
actionview (= 4.2.11.1)
|
31
|
+
activesupport (= 4.2.11.1)
|
32
|
+
rack (~> 1.6)
|
33
|
+
rack-test (~> 0.6.2)
|
34
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
35
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
36
|
+
actionview (4.2.11.1)
|
37
|
+
activesupport (= 4.2.11.1)
|
38
|
+
builder (~> 3.1)
|
39
|
+
erubis (~> 2.7.0)
|
40
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
41
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
42
|
+
activejob (4.2.11.1)
|
43
|
+
activesupport (= 4.2.11.1)
|
44
|
+
globalid (>= 0.3.0)
|
45
|
+
activemodel (4.2.11.1)
|
46
|
+
activesupport (= 4.2.11.1)
|
33
47
|
builder (~> 3.1)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
activesupport (6.0.4.7)
|
41
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
42
|
-
i18n (>= 0.7, < 2)
|
48
|
+
activerecord (4.2.11.1)
|
49
|
+
activemodel (= 4.2.11.1)
|
50
|
+
activesupport (= 4.2.11.1)
|
51
|
+
arel (~> 6.0)
|
52
|
+
activesupport (4.2.11.1)
|
53
|
+
i18n (~> 0.7)
|
43
54
|
minitest (~> 5.1)
|
55
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
44
56
|
tzinfo (~> 1.1)
|
45
|
-
|
46
|
-
appraisal (2.2.0)
|
47
|
-
bundler
|
48
|
-
rake
|
49
|
-
thor (>= 0.14.0)
|
57
|
+
arel (6.0.4)
|
50
58
|
ast (2.4.0)
|
51
|
-
builder (3.2.
|
52
|
-
byebug (11.1.3)
|
59
|
+
builder (3.2.3)
|
53
60
|
coderay (1.1.2)
|
54
|
-
concurrent-ruby (1.1.
|
55
|
-
contextual_logger (
|
61
|
+
concurrent-ruby (1.1.5)
|
62
|
+
contextual_logger (0.3.1)
|
56
63
|
activesupport
|
57
64
|
json
|
58
|
-
crass (1.0.
|
59
|
-
|
60
|
-
digest (3.1.0)
|
61
|
-
erubi (1.10.0)
|
62
|
-
escalate (0.3.0)
|
65
|
+
crass (1.0.4)
|
66
|
+
erubis (2.7.0)
|
63
67
|
eventmachine (1.2.7)
|
64
|
-
globalid (
|
65
|
-
activesupport (>=
|
66
|
-
|
67
|
-
|
68
|
+
globalid (0.4.2)
|
69
|
+
activesupport (>= 4.2.0)
|
70
|
+
hobo_support (2.2.6)
|
71
|
+
rails (~> 4.2.6)
|
72
|
+
i18n (0.9.5)
|
68
73
|
concurrent-ruby (~> 1.0)
|
69
|
-
invoca-utils (0.
|
74
|
+
invoca-utils (0.0.5)
|
70
75
|
jaro_winkler (1.5.3)
|
71
|
-
json (2.
|
72
|
-
loofah (2.
|
76
|
+
json (2.3.0)
|
77
|
+
loofah (2.2.3)
|
73
78
|
crass (~> 1.0.2)
|
74
79
|
nokogiri (>= 1.5.9)
|
75
80
|
mail (2.7.1)
|
76
81
|
mini_mime (>= 0.1.1)
|
77
82
|
method_source (0.9.2)
|
78
|
-
mini_mime (1.1
|
79
|
-
mini_portile2 (2.
|
80
|
-
minitest (5.
|
81
|
-
|
82
|
-
|
83
|
-
net-smtp (0.3.1)
|
84
|
-
digest
|
85
|
-
net-protocol
|
86
|
-
timeout
|
87
|
-
nokogiri (1.13.3)
|
88
|
-
mini_portile2 (~> 2.8.0)
|
89
|
-
racc (~> 1.4)
|
83
|
+
mini_mime (1.0.1)
|
84
|
+
mini_portile2 (2.4.0)
|
85
|
+
minitest (5.11.3)
|
86
|
+
nokogiri (1.10.4)
|
87
|
+
mini_portile2 (~> 2.4.0)
|
90
88
|
parallel (1.17.0)
|
91
89
|
parser (2.6.3.0)
|
92
90
|
ast (~> 2.4.0)
|
93
|
-
power_assert (1.2.0)
|
94
91
|
pry (0.12.2)
|
95
92
|
coderay (~> 1.1.0)
|
96
93
|
method_source (~> 0.9.0)
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
94
|
+
rack (1.6.11)
|
95
|
+
rack-test (0.6.3)
|
96
|
+
rack (>= 1.0)
|
97
|
+
rails (4.2.11.1)
|
98
|
+
actionmailer (= 4.2.11.1)
|
99
|
+
actionpack (= 4.2.11.1)
|
100
|
+
actionview (= 4.2.11.1)
|
101
|
+
activejob (= 4.2.11.1)
|
102
|
+
activemodel (= 4.2.11.1)
|
103
|
+
activerecord (= 4.2.11.1)
|
104
|
+
activesupport (= 4.2.11.1)
|
105
|
+
bundler (>= 1.3.0, < 2.0)
|
106
|
+
railties (= 4.2.11.1)
|
107
|
+
sprockets-rails
|
108
|
+
rails-deprecated_sanitizer (1.0.3)
|
109
|
+
activesupport (>= 4.2.0.alpha)
|
110
|
+
rails-dom-testing (1.0.9)
|
111
|
+
activesupport (>= 4.2.0, < 5.0)
|
112
|
+
nokogiri (~> 1.6)
|
113
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
114
|
+
rails-html-sanitizer (1.0.4)
|
115
|
+
loofah (~> 2.2, >= 2.2.2)
|
116
|
+
railties (4.2.11.1)
|
117
|
+
actionpack (= 4.2.11.1)
|
118
|
+
activesupport (= 4.2.11.1)
|
119
|
+
rake (>= 0.8.7)
|
120
|
+
thor (>= 0.18.1, < 2.0)
|
110
121
|
rainbow (3.0.0)
|
111
|
-
rake (
|
112
|
-
|
113
|
-
rspec-core (~> 3.9.0)
|
114
|
-
rspec-expectations (~> 3.9.0)
|
115
|
-
rspec-mocks (~> 3.9.0)
|
116
|
-
rspec-core (3.9.2)
|
117
|
-
rspec-support (~> 3.9.3)
|
118
|
-
rspec-expectations (3.9.2)
|
119
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
120
|
-
rspec-support (~> 3.9.0)
|
121
|
-
rspec-mocks (3.9.1)
|
122
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
123
|
-
rspec-support (~> 3.9.0)
|
124
|
-
rspec-support (3.9.4)
|
125
|
-
rspec_junit_formatter (0.4.1)
|
126
|
-
rspec-core (>= 2, < 4, != 2.12.0)
|
122
|
+
rake (12.3.2)
|
123
|
+
rr (1.2.1)
|
127
124
|
rubocop (0.74.0)
|
128
125
|
jaro_winkler (~> 1.5.1)
|
129
126
|
parallel (~> 1.10)
|
@@ -132,32 +129,39 @@ GEM
|
|
132
129
|
ruby-progressbar (~> 1.7)
|
133
130
|
unicode-display_width (>= 1.4.0, < 1.7)
|
134
131
|
ruby-progressbar (1.10.1)
|
135
|
-
|
136
|
-
|
132
|
+
shoulda (3.6.0)
|
133
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
134
|
+
shoulda-matchers (~> 3.0)
|
135
|
+
shoulda-context (1.2.2)
|
136
|
+
shoulda-matchers (3.1.3)
|
137
|
+
activesupport (>= 4.0.0)
|
138
|
+
sprockets (3.7.2)
|
139
|
+
concurrent-ruby (~> 1.0)
|
140
|
+
rack (> 1, < 3)
|
141
|
+
sprockets-rails (3.2.1)
|
142
|
+
actionpack (>= 4.0)
|
143
|
+
activesupport (>= 4.0)
|
144
|
+
sprockets (>= 3.0.0)
|
137
145
|
thor (1.0.1)
|
138
146
|
thread_safe (0.3.6)
|
139
|
-
|
140
|
-
tzinfo (1.2.9)
|
147
|
+
tzinfo (1.2.5)
|
141
148
|
thread_safe (~> 0.1)
|
142
149
|
unicode-display_width (1.6.0)
|
143
|
-
zeitwerk (2.5.4)
|
144
150
|
|
145
151
|
PLATFORMS
|
146
152
|
ruby
|
147
153
|
|
148
154
|
DEPENDENCIES
|
149
|
-
actionmailer (
|
150
|
-
|
151
|
-
|
155
|
+
actionmailer (>= 4.2.11.1)
|
156
|
+
actionpack (>= 4.2.11.1)
|
157
|
+
activesupport (>= 4.2.11.1)
|
152
158
|
exception_handling!
|
153
|
-
honeybadger (
|
159
|
+
honeybadger (= 3.3.1.pre.1)!
|
154
160
|
pry
|
155
|
-
|
156
|
-
|
157
|
-
rspec
|
158
|
-
rspec_junit_formatter
|
161
|
+
rake (>= 0.9)
|
162
|
+
rr
|
159
163
|
rubocop
|
160
|
-
|
164
|
+
shoulda (> 3.1.1)
|
161
165
|
|
162
166
|
BUNDLED WITH
|
163
|
-
|
167
|
+
1.17.2
|
data/README.md
CHANGED
@@ -2,10 +2,6 @@
|
|
2
2
|
|
3
3
|
Enable emails for your exceptions that occur in your application!
|
4
4
|
|
5
|
-
## Dependencies
|
6
|
-
- Ruby 2.6
|
7
|
-
- Rails >= 4.2, < 7
|
8
|
-
|
9
5
|
## Installation
|
10
6
|
|
11
7
|
Add this line to your application's Gemfile:
|
@@ -93,15 +89,15 @@ There is another hook available intended for custom actions after an error email
|
|
93
89
|
else
|
94
90
|
Invoca::Metrics::Client.metrics.counter("exception_handling/exception")
|
95
91
|
end
|
96
|
-
|
92
|
+
|
97
93
|
case honeybadger_status
|
98
94
|
when :success
|
99
95
|
Invoca::Metrics::Client.metrics.counter("exception_handling.honeybadger.success")
|
100
|
-
when :failure
|
96
|
+
when :failure
|
101
97
|
Invoca::Metrics::Client.metrics.counter("exception_handling.honeybadger.failure")
|
102
98
|
when :skipped
|
103
99
|
Invoca::Metrics::Client.metrics.counter("exception_handling.honeybadger.skipped")
|
104
|
-
end
|
100
|
+
end
|
105
101
|
end
|
106
102
|
ExceptionHandling.post_log_error_hook = method(:log_error_metrics)
|
107
103
|
|
data/Rakefile
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require 'rake/testtask'
|
5
4
|
require "bundler/gem_tasks"
|
5
|
+
require 'rake/testtask'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
namespace :test do
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.name = :unit
|
10
|
+
t.libs << "test"
|
11
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
Rake::Task['test:unit'].comment = "Run the unit tests"
|
13
15
|
end
|
14
16
|
|
15
|
-
task
|
17
|
+
task test: 'test:unit'
|
18
|
+
task default: 'test'
|
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 = ["Colin Kelley"]
|
7
|
+
spec.email = ["colindkelley@gmail.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($OUTPUT_RECORD_SEPARATOR)
|
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"
|
@@ -20,13 +20,11 @@ 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'
|
27
|
-
spec.add_dependency '
|
28
|
-
spec.add_dependency '
|
29
|
-
spec.add_dependency 'invoca-utils',
|
30
|
-
spec.add_dependency 'psych', '~> 3.0'
|
31
|
-
spec.add_dependency 'net-smtp'
|
23
|
+
spec.add_dependency 'actionmailer', '~> 4.2'
|
24
|
+
spec.add_dependency 'actionpack', '~> 4.2'
|
25
|
+
spec.add_dependency 'activesupport', '~> 4.2'
|
26
|
+
spec.add_dependency 'contextual_logger'
|
27
|
+
spec.add_dependency 'eventmachine', '~> 1.0'
|
28
|
+
spec.add_dependency 'hobo_support'
|
29
|
+
spec.add_dependency 'invoca-utils', '~> 0.0'
|
32
30
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ExceptionHandling
|
4
4
|
class ExceptionInfo
|
5
5
|
|
6
|
-
|
6
|
+
ENVIRONMENT_WHITELIST = [
|
7
7
|
/^HTTP_/,
|
8
8
|
/^QUERY_/,
|
9
9
|
/^REQUEST_/,
|
@@ -46,19 +46,16 @@ module ExceptionHandling
|
|
46
46
|
EOS
|
47
47
|
|
48
48
|
SECTIONS = [:request, :session, :environment, :backtrace, :event_response].freeze
|
49
|
-
HONEYBADGER_CONTEXT_SECTIONS = [:timestamp, :error_class, :exception_context, :server, :scm_revision, :notes,
|
50
|
-
:user_details, :request, :session, :environment, :backtrace, :event_response, :log_context].freeze
|
49
|
+
HONEYBADGER_CONTEXT_SECTIONS = [:timestamp, :error_class, :exception_context, :server, :scm_revision, :notes, :user_details, :request, :session, :environment, :backtrace, :event_response].freeze
|
51
50
|
|
52
51
|
attr_reader :exception, :controller, :exception_context, :timestamp
|
53
52
|
|
54
|
-
def initialize(exception, exception_context, timestamp, controller
|
53
|
+
def initialize(exception, exception_context, timestamp, controller = nil, data_callback = nil)
|
55
54
|
@exception = exception
|
56
55
|
@exception_context = exception_context
|
57
56
|
@timestamp = timestamp
|
58
57
|
@controller = controller || controller_from_context(exception_context)
|
59
58
|
@data_callback = data_callback
|
60
|
-
# merge into the surrounding context just like ContextualLogger does when logging
|
61
|
-
@merged_log_context = ExceptionHandling.logger.current_context_for_thread.deep_merge(log_context || {})
|
62
59
|
end
|
63
60
|
|
64
61
|
def data
|
@@ -82,10 +79,9 @@ module ExceptionHandling
|
|
82
79
|
end
|
83
80
|
|
84
81
|
def controller_name
|
85
|
-
@controller_name ||=
|
86
|
-
|
87
|
-
|
88
|
-
).to_s
|
82
|
+
@controller_name ||= if @controller
|
83
|
+
@controller.request.parameters.with_indifferent_access[:controller]
|
84
|
+
end.to_s
|
89
85
|
end
|
90
86
|
|
91
87
|
private
|
@@ -180,7 +176,7 @@ module ExceptionHandling
|
|
180
176
|
|
181
177
|
def clean_environment(env)
|
182
178
|
Hash[ env.map do |k, v|
|
183
|
-
[k, v] if !"#{k}: #{v}".in?(ENVIRONMENT_OMIT) &&
|
179
|
+
[k, v] if !"#{k}: #{v}".in?(ENVIRONMENT_OMIT) && ENVIRONMENT_WHITELIST.any? { |regex| k =~ regex }
|
184
180
|
end.compact ]
|
185
181
|
end
|
186
182
|
|
@@ -271,13 +267,14 @@ module ExceptionHandling
|
|
271
267
|
data = enhanced_data.dup
|
272
268
|
data[:server] = ExceptionHandling.server_name
|
273
269
|
data[:exception_context] = deep_clean_hash(@exception_context) if @exception_context.present?
|
274
|
-
data[:log_context] = @merged_log_context
|
275
270
|
unstringify_sections(data)
|
276
|
-
HONEYBADGER_CONTEXT_SECTIONS.
|
271
|
+
context_data = HONEYBADGER_CONTEXT_SECTIONS.reduce({}) do |context, section|
|
277
272
|
if data[section].present?
|
278
273
|
context[section] = data[section]
|
279
274
|
end
|
275
|
+
context
|
280
276
|
end
|
277
|
+
context_data
|
281
278
|
end
|
282
279
|
end
|
283
280
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ExceptionHandling
|
4
|
+
module HoneybadgerCallbacks
|
5
|
+
class << self
|
6
|
+
def register_callbacks
|
7
|
+
if ExceptionHandling.honeybadger_defined?
|
8
|
+
Honeybadger.local_variable_filter(&method(:local_variable_filter))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def inspect_object(object, filter_keys)
|
15
|
+
inspection_output = object.inspect
|
16
|
+
|
17
|
+
if contains_filter_key?(filter_keys, inspection_output)
|
18
|
+
filtered_object(object)
|
19
|
+
else
|
20
|
+
inspection_output
|
21
|
+
end
|
22
|
+
rescue => ex
|
23
|
+
details = if object.respond_to?(:to_pk)
|
24
|
+
" @pk=#{object.to_pk}"
|
25
|
+
elsif object.respond_to?(:id)
|
26
|
+
" @id=#{object.id}"
|
27
|
+
end
|
28
|
+
|
29
|
+
"#<#{object.class.name}#{details} [error '#{ex.class.name}: #{ex.message}' while calling #inspect]>"
|
30
|
+
end
|
31
|
+
|
32
|
+
def local_variable_filter(_symbol, object, filter_keys)
|
33
|
+
case object
|
34
|
+
# Honeybadger will filter these data types for us
|
35
|
+
when String, Hash, Array, Set, Numeric, TrueClass, FalseClass, NilClass
|
36
|
+
object
|
37
|
+
else # handle other Ruby objects, intended for POROs
|
38
|
+
inspect_object(object, filter_keys)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def contains_filter_key?(filter_keys, string)
|
43
|
+
filter_keys._?.any? { |key| string.include?(key) }
|
44
|
+
end
|
45
|
+
|
46
|
+
def filtered_object(object)
|
47
|
+
# make the output look similar to inspect
|
48
|
+
# use [FILTERED], just like honeybadger does
|
49
|
+
if object.respond_to?(:to_pk)
|
50
|
+
"#<#{object.class.name} @pk=#{object.to_pk}, [FILTERED]>"
|
51
|
+
elsif object.respond_to?(:id)
|
52
|
+
"#<#{object.class.name} @id=#{object.id}, [FILTERED]>"
|
53
|
+
else
|
54
|
+
"#<#{object.class.name} [FILTERED]>"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,15 +1,65 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/concern'
|
4
|
-
require_relative 'logging_methods'
|
5
4
|
|
6
5
|
module ExceptionHandling
|
7
6
|
module Methods # included on models and controllers
|
8
7
|
extend ActiveSupport::Concern
|
9
|
-
include ExceptionHandling::LoggingMethods
|
10
8
|
|
11
9
|
protected
|
12
10
|
|
11
|
+
def log_error(exception_or_string, exception_context = '')
|
12
|
+
controller = self if respond_to?(:request) && respond_to?(:session)
|
13
|
+
ExceptionHandling.log_error(exception_or_string, exception_context, controller)
|
14
|
+
end
|
15
|
+
|
16
|
+
def log_error_rack(exception_or_string, exception_context = '', rack_filter = '')
|
17
|
+
ExceptionHandling.log_error_rack(exception_or_string, exception_context, rack_filter)
|
18
|
+
end
|
19
|
+
|
20
|
+
def log_warning(message)
|
21
|
+
ExceptionHandling.log_warning(message)
|
22
|
+
end
|
23
|
+
|
24
|
+
def log_info(message)
|
25
|
+
ExceptionHandling.logger.info(message)
|
26
|
+
end
|
27
|
+
|
28
|
+
def log_debug(message)
|
29
|
+
ExceptionHandling.logger.debug(message)
|
30
|
+
end
|
31
|
+
|
32
|
+
def ensure_safe(exception_context = "")
|
33
|
+
yield
|
34
|
+
rescue => ex
|
35
|
+
log_error ex, exception_context
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def escalate_error(exception_or_string, email_subject)
|
40
|
+
ExceptionHandling.escalate_error(exception_or_string, email_subject)
|
41
|
+
end
|
42
|
+
|
43
|
+
def escalate_warning(message, email_subject)
|
44
|
+
ExceptionHandling.escalate_warning(message, email_subject)
|
45
|
+
end
|
46
|
+
|
47
|
+
def ensure_escalation(*args)
|
48
|
+
ExceptionHandling.ensure_escalation(*args) do
|
49
|
+
yield
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def alert_warning(*args)
|
54
|
+
ExceptionHandling.alert_warning(*args)
|
55
|
+
end
|
56
|
+
|
57
|
+
def ensure_alert(*args)
|
58
|
+
ExceptionHandling.ensure_alert(*args) do
|
59
|
+
yield
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
13
63
|
def long_controller_action_timeout
|
14
64
|
if defined?(Rails) && Rails.respond_to?(:env) && Rails.env == 'test'
|
15
65
|
300
|
@@ -38,10 +88,7 @@ module ExceptionHandling
|
|
38
88
|
end
|
39
89
|
|
40
90
|
included do
|
41
|
-
|
42
|
-
if respond_to? :around_filter
|
43
|
-
around_filter :set_current_controller
|
44
|
-
end
|
91
|
+
around_filter :set_current_controller if respond_to? :around_filter
|
45
92
|
end
|
46
93
|
|
47
94
|
class_methods do
|