enhanced_errors 3.0.5 → 3.0.6
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/README.md +2 -2
- data/enhanced_errors.gemspec +1 -1
- data/lib/enhanced_errors.rb +13 -4
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: eecb34c7dc88e51c162183c3d2d2701c54fc42cffc69a30aa8d713b643fce9c9
         | 
| 4 | 
            +
              data.tar.gz: 36942532b9f4f17f1b4987a92200bc30bee102f2759b75038adf2f299f6afed7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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 | 
            -
              #  | 
| 51 | 
            -
              # Consider driving the config with an environment variable  | 
| 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
         | 
    
        data/enhanced_errors.gemspec
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            Gem::Specification.new do |spec|
         | 
| 2 2 | 
             
              spec.name = "enhanced_errors"
         | 
| 3 | 
            -
              spec.version = "3.0. | 
| 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."
         | 
    
        data/lib/enhanced_errors.rb
    CHANGED
    
    | @@ -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:: | 
| 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 | 
            -
                       | 
| 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 | 
            -
                   | 
| 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. | 
| 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- | 
| 10 | 
            +
            date: 2024-12-26 00:00:00.000000000 Z
         | 
| 11 11 | 
             
            dependencies:
         | 
| 12 12 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 13 13 | 
             
              name: awesome_print
         |