exception_handling 2.9.0.pre.1 → 2.10.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/.github/workflows/pipeline.yml +27 -0
- data/CHANGELOG.md +9 -1
- data/Gemfile +6 -1
- data/Gemfile.lock +6 -13
- data/exception_handling.gemspec +1 -1
- data/gemfiles/rails_4.gemfile +1 -2
- data/gemfiles/rails_5.gemfile +1 -2
- data/gemfiles/rails_6.gemfile +1 -2
- data/lib/exception_handling/version.rb +1 -1
- data/lib/exception_handling.rb +0 -2
- data/spec/unit/exception_handling/escalate_callback_spec.rb +2 -2
- metadata +10 -15
- data/.jenkins/Jenkinsfile +0 -113
- data/.jenkins/ruby_build_pod.yml +0 -18
- data/gemfiles/.bundle/config +0 -2
- data/lib/exception_handling/honeybadger_callbacks.rb +0 -59
- data/spec/unit/exception_handling/honeybadger_callbacks_spec.rb +0 -122
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e763184c01adcad3d7646acd0056acba133b8b4577adcea9d818299415ffe1
|
4
|
+
data.tar.gz: 9a2926dc4c47ced6a5c2ac0fc2f86b12189908d24fb45ae351fb475962cf0c89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fc45419b536c099ecbef6e4fd65a6d8f552d4ac0ea41299edd5168663f3f9836b5cc19f88fedb44e3efd3b0cb7cf5e8bcdbb3c21538db59e97b92361405ae87
|
7
|
+
data.tar.gz: 5e0c693a7425006354f8b77af27a7edc6e18b326d0040dd894c3e96da144e61d11a50ec16511e95a1ed07ed5c37d6a5b55b5c3b85a8888d3216be9e51a96d03c
|
@@ -0,0 +1,27 @@
|
|
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]
|
12
|
+
gemfile:
|
13
|
+
- Gemfile
|
14
|
+
- gemfiles/rails_4.gemfile
|
15
|
+
- gemfiles/rails_5.gemfile
|
16
|
+
- gemfiles/rails_6.gemfile
|
17
|
+
env:
|
18
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler: 1.17.3
|
25
|
+
bundler-cache: true
|
26
|
+
- name: Unit tests
|
27
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,15 @@ 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.
|
7
|
+
## [2.10.0] - Unreleased
|
8
|
+
### Removed
|
9
|
+
- Remove custom object inspection
|
10
|
+
This removed Honeybadger-specific callbacks (`lib/exception_handling/honeybadger_callbacks.rb`)
|
11
|
+
|
12
|
+
### Deprecated
|
13
|
+
- Deprecated use of Honeybadger fork
|
14
|
+
|
15
|
+
## [2.9.0] - 2020-03-02
|
8
16
|
### Added
|
9
17
|
- Automatically registers with the `escalate` gem's `on_escalate` callback.
|
10
18
|
|
data/Gemfile
CHANGED
@@ -2,12 +2,17 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
+
git_source(:github) do |repo_name|
|
6
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
7
|
+
"https://github.com/#{repo_name}.git"
|
8
|
+
end
|
9
|
+
|
5
10
|
gemspec
|
6
11
|
|
7
12
|
gem 'actionmailer', '< 6.1'
|
8
13
|
gem 'activesupport', '< 6.1'
|
9
14
|
gem 'appraisal', '~> 2.2'
|
10
|
-
gem 'honeybadger'
|
15
|
+
gem 'honeybadger'
|
11
16
|
gem 'pry'
|
12
17
|
gem 'pry-byebug'
|
13
18
|
gem 'rake'
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,12 @@
|
|
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
|
-
|
8
1
|
PATH
|
9
2
|
remote: .
|
10
3
|
specs:
|
11
|
-
exception_handling (2.
|
4
|
+
exception_handling (2.10.0.pre.2)
|
12
5
|
actionmailer (>= 4.2, < 7.0)
|
13
6
|
actionpack (>= 4.2, < 7.0)
|
14
7
|
activesupport (>= 4.2, < 7.0)
|
15
8
|
contextual_logger (~> 0.7)
|
16
|
-
escalate (
|
9
|
+
escalate (~> 0.3)
|
17
10
|
eventmachine (~> 1.0)
|
18
11
|
invoca-utils (~> 0.3)
|
19
12
|
|
@@ -63,16 +56,16 @@ GEM
|
|
63
56
|
crass (1.0.6)
|
64
57
|
diff-lcs (1.4.4)
|
65
58
|
erubi (1.10.0)
|
66
|
-
escalate (0.
|
67
|
-
activesupport
|
59
|
+
escalate (0.3.0)
|
68
60
|
eventmachine (1.2.7)
|
69
61
|
globalid (0.4.2)
|
70
62
|
activesupport (>= 4.2.0)
|
63
|
+
honeybadger (4.11.0)
|
71
64
|
i18n (1.8.9)
|
72
65
|
concurrent-ruby (~> 1.0)
|
73
66
|
invoca-utils (0.4.1)
|
74
67
|
jaro_winkler (1.5.3)
|
75
|
-
json (2.
|
68
|
+
json (2.6.1)
|
76
69
|
loofah (2.9.0)
|
77
70
|
crass (~> 1.0.2)
|
78
71
|
nokogiri (>= 1.5.9)
|
@@ -146,7 +139,7 @@ DEPENDENCIES
|
|
146
139
|
activesupport (< 6.1)
|
147
140
|
appraisal (~> 2.2)
|
148
141
|
exception_handling!
|
149
|
-
honeybadger
|
142
|
+
honeybadger
|
150
143
|
pry
|
151
144
|
pry-byebug
|
152
145
|
rake
|
data/exception_handling.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'actionpack', '>= 4.2', '< 7.0'
|
25
25
|
spec.add_dependency 'activesupport', '>= 4.2', '< 7.0'
|
26
26
|
spec.add_dependency 'contextual_logger', '~> 0.7'
|
27
|
-
spec.add_dependency 'escalate', '0.
|
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
30
|
end
|
data/gemfiles/rails_4.gemfile
CHANGED
@@ -5,8 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
gem "actionmailer", "~> 4.2"
|
6
6
|
gem "activesupport", "~> 4.2"
|
7
7
|
gem "appraisal", "~> 2.2"
|
8
|
-
gem "
|
9
|
-
gem "honeybadger", "3.3.1-1", git: "git@github.com:Invoca/honeybadger-ruby", ref: "bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6"
|
8
|
+
gem "honeybadger"
|
10
9
|
gem "pry"
|
11
10
|
gem "pry-byebug"
|
12
11
|
gem "rake"
|
data/gemfiles/rails_5.gemfile
CHANGED
@@ -5,8 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
gem "actionmailer", "~> 5.2"
|
6
6
|
gem "activesupport", "~> 5.2"
|
7
7
|
gem "appraisal", "~> 2.2"
|
8
|
-
gem "
|
9
|
-
gem "honeybadger", "3.3.1-1", git: "git@github.com:Invoca/honeybadger-ruby", ref: "bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6"
|
8
|
+
gem "honeybadger"
|
10
9
|
gem "pry"
|
11
10
|
gem "pry-byebug"
|
12
11
|
gem "rake"
|
data/gemfiles/rails_6.gemfile
CHANGED
@@ -5,8 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
gem "actionmailer", "~> 6.0"
|
6
6
|
gem "activesupport", "~> 6.0"
|
7
7
|
gem "appraisal", "~> 2.2"
|
8
|
-
gem "
|
9
|
-
gem "honeybadger", "3.3.1-1", git: "git@github.com:Invoca/honeybadger-ruby", ref: "bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6"
|
8
|
+
gem "honeybadger"
|
10
9
|
gem "pry"
|
11
10
|
gem "pry-byebug"
|
12
11
|
gem "rake"
|
data/lib/exception_handling.rb
CHANGED
@@ -14,7 +14,6 @@ require 'exception_handling/log_stub_error'
|
|
14
14
|
require 'exception_handling/exception_description'
|
15
15
|
require 'exception_handling/exception_catalog'
|
16
16
|
require 'exception_handling/exception_info'
|
17
|
-
require 'exception_handling/honeybadger_callbacks'
|
18
17
|
require 'exception_handling/escalate_callback'
|
19
18
|
|
20
19
|
_ = ActiveSupport::HashWithIndifferentAccess
|
@@ -291,7 +290,6 @@ module ExceptionHandling # never included
|
|
291
290
|
#
|
292
291
|
def enable_honeybadger(config = {})
|
293
292
|
Bundler.require(:honeybadger)
|
294
|
-
HoneybadgerCallbacks.register_callbacks
|
295
293
|
Honeybadger.configure do |config_klass|
|
296
294
|
config.each do |k, v|
|
297
295
|
config_klass.send(:"#{k}=", v)
|
@@ -47,7 +47,7 @@ module ExceptionHandling
|
|
47
47
|
expect(logger).to_not receive(:fatal)
|
48
48
|
expect(ExceptionHandling).to receive(:log_error).with(exception, location_message, context_hash)
|
49
49
|
|
50
|
-
TestGem.escalate(exception, location_message, context_hash)
|
50
|
+
TestGem.escalate(exception, location_message, context: context_hash)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -73,7 +73,7 @@ module ExceptionHandling
|
|
73
73
|
expect(logger).to_not receive(:fatal)
|
74
74
|
expect(ExceptionHandling).to receive(:log_error).with(exception, location_message, context_hash)
|
75
75
|
|
76
|
-
TestGem.escalate(exception, location_message, context_hash)
|
76
|
+
TestGem.escalate(exception, location_message, context: context_hash)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
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.10.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -88,16 +88,16 @@ dependencies:
|
|
88
88
|
name: escalate
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - "~>"
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.
|
93
|
+
version: '0.3'
|
94
94
|
type: :runtime
|
95
95
|
prerelease: false
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- -
|
98
|
+
- - "~>"
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: 0.
|
100
|
+
version: '0.3'
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
102
|
name: eventmachine
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,9 +133,8 @@ executables: []
|
|
133
133
|
extensions: []
|
134
134
|
extra_rdoc_files: []
|
135
135
|
files:
|
136
|
+
- ".github/workflows/pipeline.yml"
|
136
137
|
- ".gitignore"
|
137
|
-
- ".jenkins/Jenkinsfile"
|
138
|
-
- ".jenkins/ruby_build_pod.yml"
|
139
138
|
- ".rspec"
|
140
139
|
- ".rubocop.yml"
|
141
140
|
- ".ruby-version"
|
@@ -148,7 +147,6 @@ files:
|
|
148
147
|
- Rakefile
|
149
148
|
- config/exception_filters.yml
|
150
149
|
- exception_handling.gemspec
|
151
|
-
- gemfiles/.bundle/config
|
152
150
|
- gemfiles/rails_4.gemfile
|
153
151
|
- gemfiles/rails_5.gemfile
|
154
152
|
- gemfiles/rails_6.gemfile
|
@@ -157,7 +155,6 @@ files:
|
|
157
155
|
- lib/exception_handling/exception_catalog.rb
|
158
156
|
- lib/exception_handling/exception_description.rb
|
159
157
|
- lib/exception_handling/exception_info.rb
|
160
|
-
- lib/exception_handling/honeybadger_callbacks.rb
|
161
158
|
- lib/exception_handling/log_stub_error.rb
|
162
159
|
- lib/exception_handling/logging_methods.rb
|
163
160
|
- lib/exception_handling/mailer.rb
|
@@ -173,7 +170,6 @@ files:
|
|
173
170
|
- spec/unit/exception_handling/exception_catalog_spec.rb
|
174
171
|
- spec/unit/exception_handling/exception_description_spec.rb
|
175
172
|
- spec/unit/exception_handling/exception_info_spec.rb
|
176
|
-
- spec/unit/exception_handling/honeybadger_callbacks_spec.rb
|
177
173
|
- spec/unit/exception_handling/log_error_stub_spec.rb
|
178
174
|
- spec/unit/exception_handling/logging_methods_spec.rb
|
179
175
|
- spec/unit/exception_handling/mailer_spec.rb
|
@@ -188,7 +184,7 @@ licenses: []
|
|
188
184
|
metadata:
|
189
185
|
source_code_uri: https://github.com/Invoca/exception_handling
|
190
186
|
allowed_push_host: https://rubygems.org
|
191
|
-
post_install_message:
|
187
|
+
post_install_message:
|
192
188
|
rdoc_options: []
|
193
189
|
require_paths:
|
194
190
|
- lib
|
@@ -204,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
200
|
version: 1.3.1
|
205
201
|
requirements: []
|
206
202
|
rubygems_version: 3.0.3
|
207
|
-
signing_key:
|
203
|
+
signing_key:
|
208
204
|
specification_version: 4
|
209
205
|
summary: Invoca's exception handling logger/emailer layer, based on exception_notifier.
|
210
206
|
Works with Rails or EventMachine or EventMachine+Synchrony.
|
@@ -217,7 +213,6 @@ test_files:
|
|
217
213
|
- spec/unit/exception_handling/exception_catalog_spec.rb
|
218
214
|
- spec/unit/exception_handling/exception_description_spec.rb
|
219
215
|
- spec/unit/exception_handling/exception_info_spec.rb
|
220
|
-
- spec/unit/exception_handling/honeybadger_callbacks_spec.rb
|
221
216
|
- spec/unit/exception_handling/log_error_stub_spec.rb
|
222
217
|
- spec/unit/exception_handling/logging_methods_spec.rb
|
223
218
|
- spec/unit/exception_handling/mailer_spec.rb
|
data/.jenkins/Jenkinsfile
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
#!/usr/bin/groovy
|
2
|
-
@Library('jenkins-pipeline@v0.4.5')
|
3
|
-
import com.invoca.docker.*;
|
4
|
-
pipeline {
|
5
|
-
agent {
|
6
|
-
kubernetes {
|
7
|
-
defaultContainer "ruby"
|
8
|
-
yamlFile ".jenkins/ruby_build_pod.yml"
|
9
|
-
}
|
10
|
-
}
|
11
|
-
|
12
|
-
environment {
|
13
|
-
GITHUB_TOKEN = credentials('github_token')
|
14
|
-
GITHUB_KEY = credentials('github_key')
|
15
|
-
BUNDLE_GEM__FURY__IO = credentials('gemfury_deploy_token')
|
16
|
-
}
|
17
|
-
|
18
|
-
stages {
|
19
|
-
stage('Setup') {
|
20
|
-
steps {
|
21
|
-
script {
|
22
|
-
updateGitHubStatus('clean-build', 'pending', 'Unit tests.')
|
23
|
-
sh '''
|
24
|
-
# get SSH setup inside the container
|
25
|
-
eval `ssh-agent -s`
|
26
|
-
echo "$GITHUB_KEY" | ssh-add -
|
27
|
-
mkdir -p /root/.ssh
|
28
|
-
ssh-keyscan -t rsa github.com > /root/.ssh/known_hosts
|
29
|
-
|
30
|
-
bundle install
|
31
|
-
bundle exec appraisal install
|
32
|
-
'''
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
stage('Appraisals') {
|
37
|
-
parallel {
|
38
|
-
stage('Current') {
|
39
|
-
environment {
|
40
|
-
JUNIT_OUTPUT = 'spec/reports/current'
|
41
|
-
}
|
42
|
-
|
43
|
-
steps {
|
44
|
-
sh "bundle exec rspec --format RspecJunitFormatter --out ${JUNIT_OUTPUT}/rspec.xml"
|
45
|
-
}
|
46
|
-
|
47
|
-
post {
|
48
|
-
always { junit "${JUNIT_OUTPUT}/*.xml" }
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
stage('Rails 4') {
|
53
|
-
environment {
|
54
|
-
JUNIT_OUTPUT = 'spec/reports/rails-4'
|
55
|
-
}
|
56
|
-
|
57
|
-
steps {
|
58
|
-
sh "bundle exec appraisal rails-4 rspec --format RspecJunitFormatter --out ${JUNIT_OUTPUT}/rspec.xml"
|
59
|
-
}
|
60
|
-
|
61
|
-
post {
|
62
|
-
always { junit "${JUNIT_OUTPUT}/*.xml" }
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
stage('Rails 5') {
|
67
|
-
environment {
|
68
|
-
JUNIT_OUTPUT = 'spec/reports/rails-5'
|
69
|
-
}
|
70
|
-
|
71
|
-
steps {
|
72
|
-
sh "bundle exec appraisal rails-5 rspec --format RspecJunitFormatter --out ${JUNIT_OUTPUT}/rspec.xml"
|
73
|
-
}
|
74
|
-
|
75
|
-
post {
|
76
|
-
always { junit "${JUNIT_OUTPUT}/*.xml" }
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
stage('Rails 6') {
|
81
|
-
environment {
|
82
|
-
JUNIT_OUTPUT = 'spec/reports/rails-6'
|
83
|
-
}
|
84
|
-
|
85
|
-
steps {
|
86
|
-
sh "bundle exec appraisal rails-6 rspec --format RspecJunitFormatter --out ${JUNIT_OUTPUT}/rspec.xml"
|
87
|
-
}
|
88
|
-
|
89
|
-
post {
|
90
|
-
always { junit "${JUNIT_OUTPUT}/*.xml" }
|
91
|
-
}
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
post {
|
96
|
-
success { updateGitHubStatus('clean-build', 'success', 'Unit tests.') }
|
97
|
-
failure { updateGitHubStatus('clean-build', 'failure', 'Unit tests.') }
|
98
|
-
}
|
99
|
-
}
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
void updateGitHubStatus(String context, String status, String description) {
|
104
|
-
gitHubStatus([
|
105
|
-
repoSlug: 'Invoca/exception_handling',
|
106
|
-
sha: env.GIT_COMMIT,
|
107
|
-
description: description,
|
108
|
-
context: context,
|
109
|
-
targetURL: env.RUN_DISPLAY_URL,
|
110
|
-
token: env.GITHUB_TOKEN,
|
111
|
-
status: status
|
112
|
-
])
|
113
|
-
}
|
data/.jenkins/ruby_build_pod.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
---
|
2
|
-
apiVersion: v1
|
3
|
-
kind: Pod
|
4
|
-
metadata:
|
5
|
-
labels:
|
6
|
-
jenkins/exception-handling: 'true'
|
7
|
-
namespace: jenkins
|
8
|
-
name: exception-handling
|
9
|
-
spec:
|
10
|
-
containers:
|
11
|
-
- name: ruby
|
12
|
-
image: ruby:2.6.5
|
13
|
-
tty: true
|
14
|
-
resources:
|
15
|
-
requests:
|
16
|
-
memory: "100Mi"
|
17
|
-
command:
|
18
|
-
- cat
|
data/gemfiles/.bundle/config
DELETED
@@ -1,59 +0,0 @@
|
|
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,122 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.expand_path('../../spec_helper', __dir__)
|
4
|
-
|
5
|
-
module ExceptionHandling
|
6
|
-
describe HoneybadgerCallbacks do
|
7
|
-
|
8
|
-
class TestPoroWithAttribute
|
9
|
-
attr_reader :test_attribute
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@test_attribute = 'test'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class TestPoroWithFilteredAttribute
|
17
|
-
attr_reader :password
|
18
|
-
|
19
|
-
def initialize
|
20
|
-
@password = 'secret'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class TestPoroWithFilteredAttributeAndId < TestPoroWithFilteredAttribute
|
25
|
-
attr_reader :id
|
26
|
-
|
27
|
-
def initialize
|
28
|
-
super
|
29
|
-
@id = 1
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class TestPoroWithFilteredAttributePkAndId < TestPoroWithFilteredAttributeAndId
|
34
|
-
def to_pk
|
35
|
-
'TestPoroWithFilteredAttributePkAndId_1'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class TestRaiseOnInspect < TestPoroWithAttribute
|
40
|
-
def inspect
|
41
|
-
raise "some error"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class TestRaiseOnInspectWithId < TestRaiseOnInspect
|
46
|
-
def id
|
47
|
-
123
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class TestRaiseOnInspectWithToPk < TestRaiseOnInspect
|
52
|
-
def to_pk
|
53
|
-
"SomeRecord-123"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "register_callbacks" do
|
58
|
-
it "store the callbacks in the honeybadger object" do
|
59
|
-
HoneybadgerCallbacks.register_callbacks
|
60
|
-
result = Honeybadger.config.local_variable_filter.call(:variable_name, 'test', [])
|
61
|
-
expect(result).to eq('test')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context "local_variable_filter" do
|
66
|
-
it "not inspect String, Hash, Array, Set, Numeric, TrueClass, FalseClass, NilClass" do
|
67
|
-
[
|
68
|
-
['test', String],
|
69
|
-
[{ a: 1 }, Hash],
|
70
|
-
[[1, 2], Array],
|
71
|
-
[Set.new([1, 2]), Set],
|
72
|
-
[4.5, Numeric],
|
73
|
-
[true, TrueClass],
|
74
|
-
[false, FalseClass],
|
75
|
-
[nil, NilClass]
|
76
|
-
].each do |object, expected_class|
|
77
|
-
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, object, [])
|
78
|
-
expect(result.is_a?(expected_class)).to be_truthy
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it "inspect other classes" do
|
83
|
-
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestPoroWithAttribute.new, ['password'])
|
84
|
-
expect(result).to match(/#<ExceptionHandling::TestPoroWithAttribute:.* @test_attribute="test">/)
|
85
|
-
end
|
86
|
-
|
87
|
-
context "when inspect raises exceptions" do
|
88
|
-
it "handle exceptions for objects" do
|
89
|
-
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestRaiseOnInspect.new, ['password'])
|
90
|
-
expect(result).to eq("#<ExceptionHandling::TestRaiseOnInspect [error 'RuntimeError: some error' while calling #inspect]>")
|
91
|
-
end
|
92
|
-
|
93
|
-
it "handle exceptions for objects responding to id" do
|
94
|
-
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestRaiseOnInspectWithId.new, ['password'])
|
95
|
-
expect(result).to eq("#<ExceptionHandling::TestRaiseOnInspectWithId @id=123 [error 'RuntimeError: some error' while calling #inspect]>")
|
96
|
-
end
|
97
|
-
|
98
|
-
it "handle exceptions for objects responding to to_pk" do
|
99
|
-
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestRaiseOnInspectWithToPk.new, ['password'])
|
100
|
-
expect(result).to eq("#<ExceptionHandling::TestRaiseOnInspectWithToPk @pk=SomeRecord-123 [error 'RuntimeError: some error' while calling #inspect]>")
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "not inspect objects that contain filter keys" do
|
105
|
-
it "use to_pk if available, even if id is available" do
|
106
|
-
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestPoroWithFilteredAttributePkAndId.new, ['password'])
|
107
|
-
expect(result).to match(/#<ExceptionHandling::TestPoroWithFilteredAttributePkAndId @pk=TestPoroWithFilteredAttributePkAndId_1, \[FILTERED\]>/)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "use id if to_pk is not available" do
|
111
|
-
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestPoroWithFilteredAttributeAndId.new, ['password'])
|
112
|
-
expect(result).to match(/#<ExceptionHandling::TestPoroWithFilteredAttributeAndId @id=1, \[FILTERED\]>/)
|
113
|
-
end
|
114
|
-
|
115
|
-
it "print the object name if no id or to_pk" do
|
116
|
-
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestPoroWithFilteredAttribute.new, ['password'])
|
117
|
-
expect(result).to match(/#<ExceptionHandling::TestPoroWithFilteredAttribute \[FILTERED\]>/)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|