enhanced_errors 0.1.0 → 0.1.1
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/.yardoc/checksums +4 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/README.md +33 -19
- data/doc/Binding.html +137 -0
- data/doc/Colors.html +384 -0
- data/doc/Debugging.html +181 -0
- data/doc/EnhancedErrors.html +2742 -0
- data/doc/ErrorEnhancements.html +252 -0
- data/doc/_index.html +151 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +503 -0
- data/doc/file.README.html +432 -0
- data/doc/file_list.html +59 -0
- data/doc/frames.html +22 -0
- data/doc/images/enhanced-error.png +0 -0
- data/doc/index.html +432 -0
- data/doc/js/app.js +344 -0
- data/doc/js/full_list.js +242 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +286 -0
- data/doc/top-level-namespace.html +112 -0
- data/enhanced_errors.gemspec +4 -2
- data/lib/enhanced_errors.rb +43 -30
- metadata +56 -4
@@ -0,0 +1,112 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Top Level Namespace
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.37
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">Top Level Namespace</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Top Level Namespace
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<h2>Defined Under Namespace</h2>
|
82
|
+
<p class="children">
|
83
|
+
|
84
|
+
|
85
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Debugging.html" title="Debugging (module)">Debugging</a></span>, <span class='object_link'><a href="ErrorEnhancements.html" title="ErrorEnhancements (module)">ErrorEnhancements</a></span>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Binding.html" title="Binding (class)">Binding</a></span>, <span class='object_link'><a href="Colors.html" title="Colors (class)">Colors</a></span>, <span class='object_link'><a href="EnhancedErrors.html" title="EnhancedErrors (class)">EnhancedErrors</a></span>
|
90
|
+
|
91
|
+
|
92
|
+
</p>
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<div id="footer">
|
105
|
+
Generated on Tue Oct 22 23:16:25 2024 by
|
106
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
107
|
+
0.9.37 (ruby-3.1.3).
|
108
|
+
</div>
|
109
|
+
|
110
|
+
</div>
|
111
|
+
</body>
|
112
|
+
</html>
|
data/enhanced_errors.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "enhanced_errors"
|
3
|
-
spec.version = "0.1.
|
3
|
+
spec.version = "0.1.1"
|
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."
|
7
7
|
spec.description = "With no extra dependencies, and using only Ruby's built-in TracePoint, EnhancedErrors will automatically enhance your errors with messages containing variable values from the moment they were raised."
|
8
|
-
spec.homepage = "https://github.com/ericbeland/enhanced_errors
|
8
|
+
spec.homepage = "https://github.com/ericbeland/enhanced_errors"
|
9
9
|
spec.required_ruby_version = ">= 3.0.0"
|
10
10
|
|
11
11
|
spec.metadata["homepage_uri"] = spec.homepage
|
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
end
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
spec.add_development_dependency "rspec", "> 3.4.0"
|
24
|
+
spec.add_development_dependency "awesome_print", "> 1.9.0"
|
25
|
+
spec.add_development_dependency "yard", "> 0.9.33"
|
24
26
|
end
|
data/lib/enhanced_errors.rb
CHANGED
@@ -10,48 +10,59 @@ require_relative 'binding'
|
|
10
10
|
# It offers customization options for formatting and filtering captured data.
|
11
11
|
class EnhancedErrors
|
12
12
|
class << self
|
13
|
-
#
|
14
|
-
#
|
13
|
+
# Indicates whether EnhancedErrors is enabled.
|
14
|
+
#
|
15
|
+
# @return [Boolean]
|
15
16
|
attr_accessor :enabled
|
16
17
|
|
17
|
-
#
|
18
|
-
#
|
18
|
+
# The TracePoint object used for tracing exceptions.
|
19
|
+
#
|
20
|
+
# @return [TracePoint, nil]
|
19
21
|
attr_accessor :trace
|
20
22
|
|
21
|
-
#
|
22
|
-
#
|
23
|
+
# The configuration block provided during enhancement.
|
24
|
+
#
|
25
|
+
# @return [Proc, nil]
|
23
26
|
attr_accessor :config_block
|
24
27
|
|
25
|
-
#
|
26
|
-
#
|
28
|
+
# The maximum length of the formatted exception message.
|
29
|
+
#
|
30
|
+
# @return [Integer]
|
27
31
|
attr_accessor :max_length
|
28
32
|
|
29
|
-
#
|
30
|
-
#
|
33
|
+
# Hook to modify binding information upon capture.
|
34
|
+
#
|
35
|
+
# @return [Proc, nil]
|
31
36
|
attr_accessor :on_capture_hook
|
32
37
|
|
33
|
-
#
|
34
|
-
#
|
38
|
+
# Determines whether RSpec `let` variables are captured.
|
39
|
+
#
|
40
|
+
# @return [Boolean]
|
35
41
|
attr_accessor :capture_let_variables
|
36
42
|
|
37
|
-
#
|
38
|
-
#
|
43
|
+
# A proc that determines if an exception is eligible for capture.
|
44
|
+
#
|
45
|
+
# @return [Proc, nil]
|
39
46
|
attr_accessor :eligible_for_capture
|
40
47
|
|
41
|
-
#
|
42
|
-
#
|
48
|
+
# A set of variable names to exclude from binding information.
|
49
|
+
#
|
50
|
+
# @return [Set<Symbol>]
|
43
51
|
attr_accessor :skip_list
|
44
52
|
|
45
|
-
#
|
46
|
-
#
|
53
|
+
# Regular expression to identify gem paths.
|
54
|
+
#
|
55
|
+
# @return [Regexp]
|
47
56
|
GEMS_REGEX = %r{[\/\\]gems[\/\\]}
|
48
57
|
|
49
|
-
#
|
50
|
-
#
|
58
|
+
# The default maximum length for formatted exception messages.
|
59
|
+
#
|
60
|
+
# @return [Integer]
|
51
61
|
DEFAULT_MAX_LENGTH = 2500
|
52
62
|
|
53
|
-
#
|
54
|
-
#
|
63
|
+
# A set of RSpec-specific instance variables to skip.
|
64
|
+
#
|
65
|
+
# @return [Set<Symbol>]
|
55
66
|
RSPEC_SKIP_LIST = Set.new([
|
56
67
|
:@fixture_cache,
|
57
68
|
:@fixture_cache_key,
|
@@ -62,8 +73,9 @@ class EnhancedErrors
|
|
62
73
|
:@matcher_definitions,
|
63
74
|
])
|
64
75
|
|
65
|
-
#
|
66
|
-
#
|
76
|
+
# A set of Rails-specific instance variables to skip.
|
77
|
+
#
|
78
|
+
# @return [Set<Symbol>]
|
67
79
|
RAILS_SKIP_LIST = Set.new([
|
68
80
|
:@new_record,
|
69
81
|
:@attributes,
|
@@ -221,7 +233,7 @@ class EnhancedErrors
|
|
221
233
|
# Formats the captured binding information into a string based on the specified format.
|
222
234
|
#
|
223
235
|
# @param captured_bindings [Array<Hash>] The array of captured binding information.
|
224
|
-
# @param output_format [Symbol] The format to use
|
236
|
+
# @param output_format [Symbol] The format to use (:json, :plaintext, :terminal).
|
225
237
|
# @return [String] The formatted exception message.
|
226
238
|
def format(captured_bindings = [], output_format = get_default_format_for_environment)
|
227
239
|
result = binding_infos_array_to_string(captured_bindings, output_format)
|
@@ -456,6 +468,9 @@ class EnhancedErrors
|
|
456
468
|
@trace.enable
|
457
469
|
end
|
458
470
|
|
471
|
+
# Retrieves the current test name from RSpec, if available.
|
472
|
+
#
|
473
|
+
# @return [String, nil] The current test name or `nil` if not in a test context.
|
459
474
|
def test_name
|
460
475
|
return RSpec&.current_example&.full_description if defined?(RSpec)
|
461
476
|
nil
|
@@ -475,19 +490,17 @@ class EnhancedErrors
|
|
475
490
|
parameters = method_obj.parameters
|
476
491
|
locals = bind.local_variables
|
477
492
|
|
478
|
-
|
493
|
+
parameters.map do |(type, name)|
|
479
494
|
value = locals.include?(name) ? bind.local_variable_get(name) : nil
|
480
495
|
"#{name}=#{value.inspect}"
|
481
496
|
rescue => e
|
482
497
|
"#{name}=#<Error getting argument: #{e.message}>"
|
483
498
|
end.join(", ")
|
484
|
-
end
|
485
|
-
|
486
499
|
rescue => e
|
487
|
-
|
500
|
+
"#<Error getting arguments: #{e.message}>"
|
501
|
+
end
|
488
502
|
end
|
489
503
|
|
490
|
-
|
491
504
|
# Determines the object name based on the TracePoint and method name.
|
492
505
|
#
|
493
506
|
# @param tp [TracePoint] The current TracePoint.
|
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.1
|
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-10-
|
11
|
+
date: 2024-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.4.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: awesome_print
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.9.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.9.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: yard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.9.33
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.33
|
27
55
|
description: With no extra dependencies, and using only Ruby's built-in TracePoint,
|
28
56
|
EnhancedErrors will automatically enhance your errors with messages containing variable
|
29
57
|
values from the moment they were raised.
|
@@ -32,13 +60,37 @@ executables: []
|
|
32
60
|
extensions: []
|
33
61
|
extra_rdoc_files: []
|
34
62
|
files:
|
63
|
+
- ".yardoc/checksums"
|
64
|
+
- ".yardoc/complete"
|
65
|
+
- ".yardoc/object_types"
|
66
|
+
- ".yardoc/objects/root.dat"
|
67
|
+
- ".yardoc/proxy_types"
|
35
68
|
- LICENSE
|
36
69
|
- README.md
|
37
70
|
- benchmark/benchmark.rb
|
38
71
|
- benchmark/stackprofile.rb
|
72
|
+
- doc/Binding.html
|
73
|
+
- doc/Colors.html
|
74
|
+
- doc/Debugging.html
|
75
|
+
- doc/EnhancedErrors.html
|
76
|
+
- doc/ErrorEnhancements.html
|
77
|
+
- doc/_index.html
|
78
|
+
- doc/class_list.html
|
79
|
+
- doc/css/common.css
|
80
|
+
- doc/css/full_list.css
|
81
|
+
- doc/css/style.css
|
82
|
+
- doc/file.README.html
|
83
|
+
- doc/file_list.html
|
84
|
+
- doc/frames.html
|
39
85
|
- doc/images/enhance.png
|
40
86
|
- doc/images/enhanced-error.png
|
41
87
|
- doc/images/enhanced-spec.png
|
88
|
+
- doc/index.html
|
89
|
+
- doc/js/app.js
|
90
|
+
- doc/js/full_list.js
|
91
|
+
- doc/js/jquery.js
|
92
|
+
- doc/method_list.html
|
93
|
+
- doc/top-level-namespace.html
|
42
94
|
- enhanced_errors.gemspec
|
43
95
|
- examples/division_by_zero_example.rb
|
44
96
|
- examples/example_spec.rb
|
@@ -46,10 +98,10 @@ files:
|
|
46
98
|
- lib/colors.rb
|
47
99
|
- lib/enhanced_errors.rb
|
48
100
|
- lib/error_enhancements.rb
|
49
|
-
homepage: https://github.com/ericbeland/enhanced_errors
|
101
|
+
homepage: https://github.com/ericbeland/enhanced_errors
|
50
102
|
licenses: []
|
51
103
|
metadata:
|
52
|
-
homepage_uri: https://github.com/ericbeland/enhanced_errors
|
104
|
+
homepage_uri: https://github.com/ericbeland/enhanced_errors
|
53
105
|
source_code_uri: https://github.com/ericbeland/enhanced_errors
|
54
106
|
post_install_message:
|
55
107
|
rdoc_options: []
|