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 +4 -4
- data/enhanced_errors.gemspec +1 -1
- data/lib/enhanced_errors.rb +34 -10
- 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: 12d823c10e0bd52d8ca38f39e5851104676be83be50ee5d3246b339eea00b3d4
|
4
|
+
data.tar.gz: 3d2df93d9c9b9712fe62bd1b3909032ece37ed8dc32ac9453d3b751655f6df83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4952714cb57a30e8100889c7e275d96626abdb41b9bae9a894f4e8eb9d74de429d0bc9d3e1b8848cc89759d017258044c71014453186ffde80d5b19b90d1ce54
|
7
|
+
data.tar.gz: 152b2feb1962389acf32e13ad965bb0959f5aed731840cf96979c840a2dd1e9843a599821b5b54acf599bf74cf0c4a9f90e21c34e6837aab412826a6662d072c
|
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 = "0.1.
|
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."
|
data/lib/enhanced_errors.rb
CHANGED
@@ -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] ||
|
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
|
-
|
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
|
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
|
-
|
632
|
+
if awesome_print_available? && Colors.enabled?
|
633
|
+
variable.ai
|
634
|
+
else
|
635
|
+
variable.inspect
|
636
|
+
end
|
618
637
|
rescue => e
|
619
|
-
|
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.
|
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
|
+
date: 2024-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|