exception_handling 2.9.0 → 3.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -3
  3. data/.ruby-version +1 -1
  4. data/Gemfile +16 -11
  5. data/Gemfile.lock +104 -96
  6. data/README.md +3 -7
  7. data/Rakefile +11 -8
  8. data/exception_handling.gemspec +10 -10
  9. data/lib/exception_handling/exception_info.rb +10 -13
  10. data/lib/exception_handling/honeybadger_callbacks.rb +1 -1
  11. data/lib/exception_handling/log_stub_error.rb +1 -2
  12. data/lib/exception_handling/methods.rb +53 -6
  13. data/lib/exception_handling/testing.rb +10 -20
  14. data/lib/exception_handling/version.rb +1 -1
  15. data/lib/exception_handling.rb +13 -42
  16. data/semaphore_ci/setup.sh +3 -0
  17. data/{spec → test}/helpers/controller_helpers.rb +0 -0
  18. data/{spec → test}/helpers/exception_helpers.rb +2 -2
  19. data/{spec/spec_helper.rb → test/test_helper.rb} +42 -63
  20. data/test/unit/exception_handling/exception_catalog_test.rb +85 -0
  21. data/test/unit/exception_handling/exception_description_test.rb +82 -0
  22. data/{spec/unit/exception_handling/exception_info_spec.rb → test/unit/exception_handling/exception_info_test.rb} +114 -153
  23. data/{spec/unit/exception_handling/honeybadger_callbacks_spec.rb → test/unit/exception_handling/honeybadger_callbacks_test.rb} +20 -20
  24. data/{spec/unit/exception_handling/log_error_stub_spec.rb → test/unit/exception_handling/log_error_stub_test.rb} +22 -38
  25. data/{spec/unit/exception_handling/mailer_spec.rb → test/unit/exception_handling/mailer_test.rb} +18 -17
  26. data/test/unit/exception_handling/methods_test.rb +84 -0
  27. data/test/unit/exception_handling/sensu_test.rb +52 -0
  28. data/test/unit/exception_handling_test.rb +1109 -0
  29. metadata +53 -86
  30. data/.jenkins/Jenkinsfile +0 -113
  31. data/.jenkins/ruby_build_pod.yml +0 -18
  32. data/.rspec +0 -3
  33. data/Appraisals +0 -19
  34. data/CHANGELOG.md +0 -77
  35. data/gemfiles/.bundle/config +0 -2
  36. data/gemfiles/rails_4.gemfile +0 -19
  37. data/gemfiles/rails_5.gemfile +0 -19
  38. data/gemfiles/rails_6.gemfile +0 -19
  39. data/lib/exception_handling/escalate_callback.rb +0 -19
  40. data/lib/exception_handling/logging_methods.rb +0 -27
  41. data/spec/rake_test_warning_false.rb +0 -20
  42. data/spec/unit/exception_handling/escalate_callback_spec.rb +0 -81
  43. data/spec/unit/exception_handling/exception_catalog_spec.rb +0 -85
  44. data/spec/unit/exception_handling/exception_description_spec.rb +0 -82
  45. data/spec/unit/exception_handling/logging_methods_spec.rb +0 -38
  46. data/spec/unit/exception_handling/methods_spec.rb +0 -105
  47. data/spec/unit/exception_handling/sensu_spec.rb +0 -51
  48. data/spec/unit/exception_handling_spec.rb +0 -1249
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 98d4a360c553e3d8505ddf0d0de7d4028416f3e1bd62f513b9848dfa95de7cf3
4
- data.tar.gz: 4e4ee581d5fb7f4490b1db162ba49113eee07b748a32f0854a53801633156a73
2
+ SHA1:
3
+ metadata.gz: 6aee76b81d1d4742150afdeb95f8a6f544671a3f
4
+ data.tar.gz: 4822461573c54709a2d977b82e47de35cecfa51e
5
5
  SHA512:
6
- metadata.gz: f6b7f7e6d8ccd286e97aec2bc28833a041108a3b16043dfe437f688bbdf45a034c5b3f407ccffa06d26bfe949e7e1aa164747ea4e797fac4ace4f2dc7fce9c34
7
- data.tar.gz: fea43abeaf0400f78a975037c5e881b9a41e07b20b934fda5ac7bf35b59ca652daee4ccaa1503abafe818ad3b741edc1ec1a3665ce32e7fdc15ee91f1bb1afb4
6
+ metadata.gz: de1c0ab7cb7e7a493ce5f8c8d155ad98450edc891636e2d8e9d82ec2d8bdc312b45ba96f5902e0bc2d70adb35c0e4e20317bbea7d72d54625d7c2764ac2fb374
7
+ data.tar.gz: 7546dd2be9a2701d360cdd5fee3ea0e93b9a26e0072c835940659d5244c0e625743924cdde737fee08a7d5f909d03df1752b8e9ae6b8a7d354b62a77d8b89a57
data/.gitignore CHANGED
@@ -1,6 +1,3 @@
1
1
  .idea
2
2
  .DS_Store
3
3
  .rubocop-http*
4
- spec/reports/*
5
- gemfiles/*.lock
6
- pkg/
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.5
1
+ 2.4.2
data/Gemfile CHANGED
@@ -2,16 +2,21 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ # Specify your gem's dependencies in attr_default.gemspec
5
6
  gemspec
6
7
 
7
- gem 'actionmailer', '< 6.1'
8
- gem 'activesupport', '< 6.1'
9
- gem 'appraisal', '~> 2.2'
10
- gem 'honeybadger', '3.3.1-1', git: 'git@github.com:Invoca/honeybadger-ruby', ref: 'bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6'
11
- gem 'pry'
12
- gem 'pry-byebug'
13
- gem 'rake'
14
- gem 'rspec'
15
- gem 'rspec_junit_formatter'
16
- gem 'rubocop'
17
- gem 'test-unit'
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
@@ -8,119 +8,119 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- exception_handling (2.9.0)
12
- actionmailer (>= 4.2, < 7.0)
13
- actionpack (>= 4.2, < 7.0)
14
- activesupport (>= 4.2, < 7.0)
15
- contextual_logger (~> 0.7)
16
- escalate (~> 0.2)
11
+ exception_handling (3.0.pre.1)
12
+ actionmailer (~> 4.2)
13
+ actionpack (~> 4.2)
14
+ activesupport (~> 4.2)
15
+ contextual_logger
17
16
  eventmachine (~> 1.0)
18
- invoca-utils (~> 0.3)
17
+ hobo_support
18
+ invoca-utils (~> 0.0)
19
19
 
20
20
  GEM
21
21
  remote: https://rubygems.org/
22
22
  specs:
23
- actionmailer (6.0.3.5)
24
- actionpack (= 6.0.3.5)
25
- actionview (= 6.0.3.5)
26
- activejob (= 6.0.3.5)
23
+ actionmailer (4.2.11.1)
24
+ actionpack (= 4.2.11.1)
25
+ actionview (= 4.2.11.1)
26
+ activejob (= 4.2.11.1)
27
27
  mail (~> 2.5, >= 2.5.4)
28
- rails-dom-testing (~> 2.0)
29
- actionpack (6.0.3.5)
30
- actionview (= 6.0.3.5)
31
- activesupport (= 6.0.3.5)
32
- rack (~> 2.0, >= 2.0.8)
33
- rack-test (>= 0.6.3)
34
- rails-dom-testing (~> 2.0)
35
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
- actionview (6.0.3.5)
37
- activesupport (= 6.0.3.5)
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
38
  builder (~> 3.1)
39
- erubi (~> 1.4)
40
- rails-dom-testing (~> 2.0)
41
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
42
- activejob (6.0.3.5)
43
- activesupport (= 6.0.3.5)
44
- globalid (>= 0.3.6)
45
- activesupport (6.0.3.5)
46
- concurrent-ruby (~> 1.0, >= 1.0.2)
47
- i18n (>= 0.7, < 2)
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)
47
+ builder (~> 3.1)
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)
48
54
  minitest (~> 5.1)
55
+ thread_safe (~> 0.3, >= 0.3.4)
49
56
  tzinfo (~> 1.1)
50
- zeitwerk (~> 2.2, >= 2.2.2)
51
- appraisal (2.2.0)
52
- bundler
53
- rake
54
- thor (>= 0.14.0)
57
+ arel (6.0.4)
55
58
  ast (2.4.0)
56
- builder (3.2.4)
57
- byebug (11.1.3)
59
+ builder (3.2.3)
58
60
  coderay (1.1.2)
59
- concurrent-ruby (1.1.8)
60
- contextual_logger (0.11.0)
61
+ concurrent-ruby (1.1.5)
62
+ contextual_logger (0.3.1)
61
63
  activesupport
62
64
  json
63
- crass (1.0.6)
64
- diff-lcs (1.4.4)
65
- erubi (1.10.0)
66
- escalate (0.2.0)
67
- activesupport
65
+ crass (1.0.4)
66
+ erubis (2.7.0)
68
67
  eventmachine (1.2.7)
69
68
  globalid (0.4.2)
70
69
  activesupport (>= 4.2.0)
71
- i18n (1.8.9)
70
+ hobo_support (2.2.6)
71
+ rails (~> 4.2.6)
72
+ i18n (0.9.5)
72
73
  concurrent-ruby (~> 1.0)
73
- invoca-utils (0.4.1)
74
+ invoca-utils (0.0.5)
74
75
  jaro_winkler (1.5.3)
75
- json (2.5.1)
76
- loofah (2.9.0)
76
+ json (2.3.0)
77
+ loofah (2.2.3)
77
78
  crass (~> 1.0.2)
78
79
  nokogiri (>= 1.5.9)
79
80
  mail (2.7.1)
80
81
  mini_mime (>= 0.1.1)
81
82
  method_source (0.9.2)
82
- mini_mime (1.0.2)
83
- mini_portile2 (2.5.0)
84
- minitest (5.14.4)
85
- nokogiri (1.11.1)
86
- mini_portile2 (~> 2.5.0)
87
- 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)
88
88
  parallel (1.17.0)
89
89
  parser (2.6.3.0)
90
90
  ast (~> 2.4.0)
91
- power_assert (1.2.0)
92
91
  pry (0.12.2)
93
92
  coderay (~> 1.1.0)
94
93
  method_source (~> 0.9.0)
95
- pry-byebug (3.8.0)
96
- byebug (~> 11.0)
97
- pry (~> 0.10)
98
- racc (1.5.2)
99
- rack (2.2.3)
100
- rack-test (1.1.0)
101
- rack (>= 1.0, < 3)
102
- rails-dom-testing (2.0.3)
103
- activesupport (>= 4.2.0)
104
- nokogiri (>= 1.6)
105
- rails-html-sanitizer (1.3.0)
106
- loofah (~> 2.3)
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)
107
121
  rainbow (3.0.0)
108
- rake (13.0.1)
109
- rspec (3.9.0)
110
- rspec-core (~> 3.9.0)
111
- rspec-expectations (~> 3.9.0)
112
- rspec-mocks (~> 3.9.0)
113
- rspec-core (3.9.2)
114
- rspec-support (~> 3.9.3)
115
- rspec-expectations (3.9.2)
116
- diff-lcs (>= 1.2.0, < 2.0)
117
- rspec-support (~> 3.9.0)
118
- rspec-mocks (3.9.1)
119
- diff-lcs (>= 1.2.0, < 2.0)
120
- rspec-support (~> 3.9.0)
121
- rspec-support (3.9.3)
122
- rspec_junit_formatter (0.4.1)
123
- rspec-core (>= 2, < 4, != 2.12.0)
122
+ rake (12.3.2)
123
+ rr (1.2.1)
124
124
  rubocop (0.74.0)
125
125
  jaro_winkler (~> 1.5.1)
126
126
  parallel (~> 1.10)
@@ -129,31 +129,39 @@ GEM
129
129
  ruby-progressbar (~> 1.7)
130
130
  unicode-display_width (>= 1.4.0, < 1.7)
131
131
  ruby-progressbar (1.10.1)
132
- test-unit (3.3.6)
133
- power_assert
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)
134
145
  thor (1.0.1)
135
146
  thread_safe (0.3.6)
136
- tzinfo (1.2.9)
147
+ tzinfo (1.2.5)
137
148
  thread_safe (~> 0.1)
138
149
  unicode-display_width (1.6.0)
139
- zeitwerk (2.4.2)
140
150
 
141
151
  PLATFORMS
142
152
  ruby
143
153
 
144
154
  DEPENDENCIES
145
- actionmailer (< 6.1)
146
- activesupport (< 6.1)
147
- appraisal (~> 2.2)
155
+ actionmailer (>= 4.2.11.1)
156
+ actionpack (>= 4.2.11.1)
157
+ activesupport (>= 4.2.11.1)
148
158
  exception_handling!
149
159
  honeybadger (= 3.3.1.pre.1)!
150
160
  pry
151
- pry-byebug
152
- rake
153
- rspec
154
- rspec_junit_formatter
161
+ rake (>= 0.9)
162
+ rr
155
163
  rubocop
156
- test-unit
164
+ shoulda (> 3.1.1)
157
165
 
158
166
  BUNDLED WITH
159
- 1.17.3
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
- require_relative 'spec/rake_test_warning_false'
8
-
9
- desc "run rspec unit tests"
10
- begin
11
- require 'rspec/core/rake_task'
12
- RSpec::Core::RakeTask.new(:rspec)
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 default: :rspec
17
+ task test: 'test:unit'
18
+ task default: 'test'
@@ -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 = ["Invoca"]
7
- spec.email = ["development@invoca.com"]
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("\n")
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,11 +20,11 @@ Gem::Specification.new do |spec|
20
20
  "allowed_push_host" => "https://rubygems.org"
21
21
  }
22
22
 
23
- spec.add_dependency 'actionmailer', '>= 4.2', '< 7.0'
24
- spec.add_dependency 'actionpack', '>= 4.2', '< 7.0'
25
- spec.add_dependency 'activesupport', '>= 4.2', '< 7.0'
26
- spec.add_dependency 'contextual_logger', '~> 0.7'
27
- spec.add_dependency 'escalate', '~> 0.2'
28
- spec.add_dependency 'eventmachine', '~> 1.0'
29
- spec.add_dependency 'invoca-utils', '~> 0.3'
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'
30
30
  end
@@ -3,7 +3,7 @@
3
3
  module ExceptionHandling
4
4
  class ExceptionInfo
5
5
 
6
- ENVIRONMENT_ALLOWLIST = [
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: nil, data_callback: nil, log_context: nil)
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
- @merged_log_context[:honeybadger_grouping] ||
87
- (@controller && @controller.request.parameters.with_indifferent_access[:controller])
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) && ENVIRONMENT_ALLOWLIST.any? { |regex| k =~ regex }
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.each_with_object({}) do |section, context|
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
@@ -40,7 +40,7 @@ module ExceptionHandling
40
40
  end
41
41
 
42
42
  def contains_filter_key?(filter_keys, string)
43
- filter_keys&.any? { |key| string.include?(key) }
43
+ filter_keys._?.any? { |key| string.include?(key) }
44
44
  end
45
45
 
46
46
  def filtered_object(object)
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Test Helper that supports Minitest::Test and Test::Unit
5
- # Used by tests in the consumers of this gem to track exceptions.
4
+ # Used by functional tests to track exceptions.
6
5
  #
7
6
 
8
7
  module LogErrorStub
@@ -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
- Deprecation3_0.deprecation_warning('ExceptionHandling::Methods', 'include LoggingMethods; in controllers, set your own around_filter to set logging context')
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
@@ -4,7 +4,7 @@
4
4
 
5
5
  module ExceptionHandling
6
6
  module Testing
7
- class ControllerStubBase
7
+ class ControllerStub
8
8
 
9
9
  class Request
10
10
  attr_accessor :parameters, :protocol, :host, :request_uri, :env, :session_options
@@ -25,7 +25,7 @@ module ExceptionHandling
25
25
  attr_accessor :around_filter_method
26
26
 
27
27
  def around_filter(method)
28
- self.around_filter_method = method
28
+ ControllerStub.around_filter_method = method
29
29
  end
30
30
  end
31
31
 
@@ -44,6 +44,14 @@ module ExceptionHandling
44
44
  end
45
45
  end
46
46
 
47
+ def simulate_around_filter(&block)
48
+ set_current_controller(&block)
49
+ end
50
+
51
+ def controller_name
52
+ "ControllerStub"
53
+ end
54
+
47
55
  def action_name
48
56
  "test_action"
49
57
  end
@@ -51,27 +59,9 @@ module ExceptionHandling
51
59
  def complete_request_uri
52
60
  "#{@request.protocol}#{@request.host}#{@request.request_uri}"
53
61
  end
54
- end
55
-
56
- class LoggingMethodsControllerStub < ControllerStubBase
57
- include ExceptionHandling::LoggingMethods
58
-
59
- def controller_name
60
- "LoggingMethodsControllerStub"
61
- end
62
- end
63
62
 
64
- class MethodsControllerStub < ControllerStubBase
65
63
  include ExceptionHandling::Methods
66
64
  set_long_controller_action_timeout 2
67
-
68
- def simulate_around_filter(&block)
69
- set_current_controller(&block)
70
- end
71
-
72
- def controller_name
73
- "MethodsControllerStub"
74
- end
75
65
  end
76
66
  end
77
67
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ExceptionHandling
4
- VERSION = '2.9.0'
4
+ VERSION = '3.0.pre.1'
5
5
  end