enhanced_errors 3.0.5 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6463163f60ad8df047c834d0722ebfc800bbb8a9b57773d064b2a22eaeead69
4
- data.tar.gz: 53c886d04c8b1c518d9a4d05262947f95ba462b9b3cd76cb913c2f2142080a6d
3
+ metadata.gz: eecb34c7dc88e51c162183c3d2d2701c54fc42cffc69a30aa8d713b643fce9c9
4
+ data.tar.gz: 36942532b9f4f17f1b4987a92200bc30bee102f2759b75038adf2f299f6afed7
5
5
  SHA512:
6
- metadata.gz: 4428ec99b50fd747204426fe2059b140ed335f38486babd0f5882380391490ce5c1ef4e97a55e3fcf0caceabe099c59f5813bb2be722ab7edb584278d6e06afd
7
- data.tar.gz: e30adc9c45a925c84bc9b97f07e8a96d351325dc74880b7ee1b38f7b02e96cafec3f91b25bedafcb87793d5c11fd90aee9ec3f1bd4c426263a17a91e6ce72acf
6
+ metadata.gz: e349ac57c07ba4c554d229e5f60202b8381c1d8c952e345c905bece6cc5fd18f2941ecbd00d57bc1357ff2d895d9b0b9d931b0127673e84a356c2c504e78b6c0
7
+ data.tar.gz: 6fc1dea986b74c34f2bcb23b189e83298349b5273e18767256c047cbdfe875d7edce6dc0d42c86c62a87824ee8acf3ed99710309b719c09b8ed559a6601a677f
data/README.md CHANGED
@@ -47,8 +47,8 @@ require 'awesome_print' # Optional, for better output
47
47
 
48
48
  RSpec.configure do |config|
49
49
 
50
- # Along with the requires, add this to your RSpec config to enhance your RSpec output
51
- # Consider driving the config with an environment variable like this to make it configurable per-user or run
50
+ # Add this config to RSpec to enhance your output
51
+ # Consider driving the config with an environment variable to make it configurable per-user or run:
52
52
  # if ENV['enhanced_errors'] == 'true'
53
53
  config.before(:example) do |_example|
54
54
  EnhancedErrors.start_rspec_binding_capture
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "enhanced_errors"
3
- spec.version = "3.0.5"
3
+ spec.version = "3.0.6"
4
4
  spec.authors = ["Eric Beland"]
5
5
 
6
6
  spec.summary = "Automatically enhance your errors with messages containing variable values from the moment they were raised."
@@ -9,7 +9,7 @@ module Enhanced; end
9
9
  # Exceptions we could handle but overlook for other reasons. These class constants are not always loaded
10
10
  # and generally are only be available when `required`, so we detect them by strings.
11
11
  IGNORED_EXCEPTIONS = %w[RSpec::Expectations::ExpectationNotMetError RSpec::Matchers::BuiltIn::RaiseError
12
- JSON::ParserError Zlib::Error OpenSSL::SSL::SSLError Psych::Exception]
12
+ JSON::ParserError Zlib::Error OpenSSL::SSL::SSLError Psych::BadAlias]
13
13
 
14
14
  class EnhancedErrors
15
15
  extend ::Enhanced
@@ -171,6 +171,7 @@ class EnhancedErrors
171
171
  end
172
172
 
173
173
  def override_exception_message(exception, binding_or_bindings)
174
+ return unless exception_is_handleable?(exception)
174
175
  variable_str = EnhancedErrors.format(binding_or_bindings)
175
176
  message_str = exception.message
176
177
  exception.define_singleton_method(:unaltered_message) { message_str }
@@ -277,13 +278,14 @@ class EnhancedErrors
277
278
  @rspec_tracepoint&.disable
278
279
  @rspec_tracepoint = TracePoint.new(:raise) do |tp|
279
280
  return unless exception_is_handleable?(tp.raised_exception)
280
- class_name = tp.raised_exception.class.name
281
- case class_name
281
+ case tp.raised_exception.class.name
282
282
  when 'RSpec::Expectations::ExpectationNotMetError'
283
283
  start_rspec_binding_trap
284
284
  else
285
285
  handle_tracepoint_event(tp)
286
286
  end
287
+ rescue => e
288
+ puts "Error in RSpec biding capture #{e} #{e.backtrace}"
287
289
  end
288
290
  end
289
291
  @rspec_tracepoint&.enable
@@ -635,8 +637,11 @@ class EnhancedErrors
635
637
  Thread.current[:enhanced_errors_processing] = false
636
638
  end
637
639
 
640
+ # Specifically avoid psych, and system level libraries, or libraries where variable context isn't
641
+ # likely to be particularly helpful or relevant.
638
642
  def ignored_exception?(exception)
639
- IGNORED_EXCEPTIONS.include?(exception.class.name)
643
+ name = exception.class.name
644
+ IGNORED_EXCEPTIONS.include?(name) || name =~ /^(Gem|Psych|Zlib|OpenSSL|DRb|Prism|Reline|Fiddle)::/
640
645
  end
641
646
 
642
647
  def test_name
@@ -822,6 +827,10 @@ class EnhancedErrors
822
827
  end
823
828
 
824
829
  def exception_is_handleable?(exception)
830
+ exception && processable_exception?(exception) && !ignored_exception?(exception)
831
+ end
832
+
833
+ def processable_exception?(exception)
825
834
  case exception
826
835
  when SystemExit, SignalException, SystemStackError, NoMemoryError
827
836
  # Non-actionable: Ignore these exceptions
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enhanced_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.5
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Beland
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-12-25 00:00:00.000000000 Z
10
+ date: 2024-12-26 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: awesome_print