enhanced_errors 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58869aa7d7b2b2e3fb4f983ec425c909fd231396920da0283dc53a84afd943fe
4
- data.tar.gz: 3ec8adc214e86d163930a0500ccb869221be072469dcc99cb0ab5f6150b851e5
3
+ metadata.gz: 12d823c10e0bd52d8ca38f39e5851104676be83be50ee5d3246b339eea00b3d4
4
+ data.tar.gz: 3d2df93d9c9b9712fe62bd1b3909032ece37ed8dc32ac9453d3b751655f6df83
5
5
  SHA512:
6
- metadata.gz: cd0dcfd36be230736ce342db302c01002b6ce06bc9e7eb967d5870121002707fc6d30cb25efc0f7cec101350d8b670db7b4168ca5759a8fe1940537de2b7e620
7
- data.tar.gz: e5d1bc47e7cc8efe21627225e520a332bc48efba549eb408d1420332f510f88f8f491ff4caf3979c07c620c9a5c5423db670ba0eec32ef769f764b0a9afdab2a
6
+ metadata.gz: 4952714cb57a30e8100889c7e275d96626abdb41b9bae9a894f4e8eb9d74de429d0bc9d3e1b8848cc89759d017258044c71014453186ffde80d5b19b90d1ce54
7
+ data.tar.gz: 152b2feb1962389acf32e13ad965bb0959f5aed731840cf96979c840a2dd1e9843a599821b5b54acf599bf74cf0c4a9f90e21c34e6837aab412826a6662d072c
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "enhanced_errors"
3
- spec.version = "0.1.6"
3
+ spec.version = "0.1.7"
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."
@@ -84,7 +84,7 @@ class EnhancedErrors
84
84
  :@connection_subscriber,
85
85
  :@saved_pool_configs,
86
86
  :@loaded_fixtures,
87
- :@matcher_definitions,
87
+ :@matcher_definitions
88
88
  ])
89
89
 
90
90
  # A set of Rails-specific instance variables to skip.
@@ -103,7 +103,12 @@ class EnhancedErrors
103
103
  :@strict_loading,
104
104
  :@strict_loading_mode,
105
105
  :@mutations_before_last_save,
106
- :@mutations_from_database
106
+ :@mutations_from_database,
107
+ :@relation_delegate_cache,
108
+ :@predicate_builder,
109
+ :@generated_relation_method,
110
+ :@find_by_statement_cache,
111
+ :@arel_table
107
112
  ])
108
113
 
109
114
  # Gets or sets the maximum length for the formatted exception message.
@@ -394,15 +399,17 @@ class EnhancedErrors
394
399
  # @return [void]
395
400
  def start_tracing
396
401
  return if @trace && @trace.enabled?
397
-
398
402
  events = @capture_events ? @capture_events.to_a : [:raise]
399
-
400
403
  @trace = TracePoint.new(*events) do |tp|
401
- next if Thread.current[:enhanced_errors_processing] || IGNORED_EXCEPTIONS.include?(tp.raised_exception)
404
+ next if Thread.current[:enhanced_errors_processing] || ignored_exception?(tp.raised_exception)
402
405
  Thread.current[:enhanced_errors_processing] = true
403
406
  exception = tp.raised_exception
404
- capture_me = EnhancedErrors.eligible_for_capture.call(exception)
405
- next unless capture_me
407
+ capture_me = !exception.frozen? && EnhancedErrors.eligible_for_capture.call(exception)
408
+
409
+ unless capture_me
410
+ Thread.current[:enhanced_errors_processing] = false
411
+ next
412
+ end
406
413
 
407
414
  exception = tp.raised_exception
408
415
  binding_context = tp.binding
@@ -487,6 +494,13 @@ class EnhancedErrors
487
494
  @trace.enable
488
495
  end
489
496
 
497
+ def ignored_exception?(exception)
498
+ IGNORED_EXCEPTIONS.each do |klass|
499
+ return true if exception.is_a?(klass)
500
+ end
501
+ false
502
+ end
503
+
490
504
 
491
505
  # Retrieves the current test name from RSpec, if available.
492
506
  #
@@ -583,7 +597,7 @@ class EnhancedErrors
583
597
  begin
584
598
  var.is_a?(Symbol) ? eval("#{var}") : nil
585
599
  rescue => e
586
- "#<Error getting value: #{e.message}>"
600
+ "#<Error getting value for #{var}>" rescue '<value error>'
587
601
  end
588
602
  end
589
603
 
@@ -613,10 +627,20 @@ class EnhancedErrors
613
627
  #
614
628
  # @param variable [Object] The variable to format.
615
629
  # @return [String] The formatted variable.
630
+
616
631
  def format_variable(variable)
617
- (awesome_print_available? && Colors.enabled?) ? variable.ai : variable.inspect
632
+ if awesome_print_available? && Colors.enabled?
633
+ variable.ai
634
+ else
635
+ variable.inspect
636
+ end
618
637
  rescue => e
619
- return "#{variable.to_s.truncate(30)}: [Inspection Error]"
638
+ var_str = begin
639
+ variable.to_s.truncate(30)
640
+ rescue
641
+ "[Unprintable variable]"
642
+ end
643
+ return "#{var_str}: [Inspection Error]"
620
644
  end
621
645
 
622
646
  # Checks if the `AwesomePrint` gem is available.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enhanced_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Beland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-10 00:00:00.000000000 Z
11
+ date: 2024-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print