enhanced_errors 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -34
- data/benchmark/result.txt +5 -7
- data/doc/Enhanced/Colors.html +2 -2
- data/doc/Enhanced/Context.html +2 -2
- data/doc/Enhanced/ExceptionBindingInfos.html +6 -12
- data/doc/Enhanced/ExceptionContext.html +2 -2
- data/doc/Enhanced.html +2 -2
- data/doc/EnhancedErrors.html +105 -101
- data/doc/Exception.html +2 -2
- data/doc/Minitest.html +2 -2
- data/doc/_index.html +2 -2
- data/doc/file.README.html +36 -46
- data/doc/index.html +36 -46
- data/doc/top-level-namespace.html +2 -2
- data/enhanced_errors.gemspec +1 -1
- data/lib/enhanced_errors.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6463163f60ad8df047c834d0722ebfc800bbb8a9b57773d064b2a22eaeead69
|
4
|
+
data.tar.gz: 53c886d04c8b1c518d9a4d05262947f95ba462b9b3cd76cb913c2f2142080a6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4428ec99b50fd747204426fe2059b140ed335f38486babd0f5882380391490ce5c1ef4e97a55e3fcf0caceabe099c59f5813bb2be722ab7edb584278d6e06afd
|
7
|
+
data.tar.gz: e30adc9c45a925c84bc9b97f07e8a96d351325dc74880b7ee1b38f7b02e96cafec3f91b25bedafcb87793d5c11fd90aee9ec3f1bd4c426263a17a91e6ce72acf
|
data/README.md
CHANGED
@@ -40,31 +40,41 @@ The RSpec test-time only approach constrained only to test-time.
|
|
40
40
|
Use EnhancedErrors with RSpec for test-specific exception capturing, ideal for CI and local testing without impacting production.
|
41
41
|
|
42
42
|
```ruby
|
43
|
+
# usually in spec_helper.rb or rails_helper.rb
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
EnhancedErrors.start_rspec_binding_capture
|
47
|
-
end
|
48
|
-
|
49
|
-
config.before(:example) do |_example|
|
50
|
-
EnhancedErrors.start_rspec_binding_capture
|
51
|
-
end
|
45
|
+
require 'enhanced_errors'
|
46
|
+
require 'awesome_print' # Optional, for better output
|
52
47
|
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
RSpec.configure do |config|
|
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
|
52
|
+
# if ENV['enhanced_errors'] == 'true'
|
53
|
+
config.before(:example) do |_example|
|
54
|
+
EnhancedErrors.start_rspec_binding_capture
|
55
|
+
end
|
56
|
+
|
57
|
+
config.before(:example) do |_example|
|
58
|
+
EnhancedErrors.start_rspec_binding_capture
|
59
|
+
end
|
60
|
+
|
61
|
+
config.after(:example) do |example|
|
62
|
+
EnhancedErrors.override_rspec_message(example, EnhancedErrors.stop_rspec_binding_capture)
|
63
|
+
end
|
64
|
+
# end
|
65
|
+
|
56
66
|
end
|
57
67
|
```
|
58
68
|
|
59
69
|
<br>
|
60
70
|
|
61
|
-
|
71
|
+
''''''
|
62
72
|
## MiniTest Setup
|
63
73
|
|
64
74
|
```ruby
|
65
75
|
require 'enhanced_errors'
|
76
|
+
require 'awesome_print' # Optional, for better output
|
66
77
|
require 'enhanced/minitest_patch'
|
67
|
-
|
68
78
|
# Once the patch is loaded, it should just work!
|
69
79
|
|
70
80
|
```
|
@@ -126,11 +136,19 @@ EnhancedErrors.enhance_exceptions!(override_messages: true)
|
|
126
136
|
<img src="./doc/images/enhanced-error.png" style="height: 215px; width: 429px;"></img>
|
127
137
|
<br>
|
128
138
|
|
139
|
+
EnhancedErrors use-cases:
|
140
|
+
* Handle test and CI failures faster by skipping that pesky "reproduction" step.
|
141
|
+
* LLM-candy - Feed debug output with variable values into your LLM, making state examine-able
|
142
|
+
* Debug deep-stack errors and reduce mean time to resolution (MTTR).
|
143
|
+
* Address elusive "Heisenbugs" by capturing full error context preemptively.
|
144
|
+
* Debug cron jobs and daemons with rich, failure-specific logs.
|
145
|
+
* Catch data-driven bugs in long jobs without re-runs or extensive logging.
|
129
146
|
|
130
147
|
|
131
148
|
## Features
|
132
149
|
|
133
150
|
- **Pure Ruby**: No external dependencies, C extensions, or C API calls.
|
151
|
+
- **Improved RSpec and Minitest errors for straight-to-fix--look-ma-no-debugging, look-ma-no-reproducing
|
134
152
|
- **Customizable Output**: Supports multiple output formats (`:json`, `:plaintext`, `:terminal`).
|
135
153
|
- **Flexible Hooks**: Redact or modifying captured data via the `on_capture` hook. Update the final string with on_format.
|
136
154
|
- **Environment-Based Defaults**: For Rails apps, automatically adjusts settings based on the environment (`development`, `test`, `production`, `ci`).
|
@@ -140,14 +158,6 @@ EnhancedErrors.enhance_exceptions!(override_messages: true)
|
|
140
158
|
- **No dependencies**: EnhancedErrors does not ___require___ any dependencies--it uses [awesome_print](https://github.com/awesome-print/awesome_print) for nicer output if it is installed and available.
|
141
159
|
- **Lightweight**: Minimal performance impact, as tracing is only active during exception raising.
|
142
160
|
|
143
|
-
EnhancedErrors use-cases:
|
144
|
-
|
145
|
-
* Catch data-driven bugs without needing re-runs or extensive logging.
|
146
|
-
* Debug deep-stack errors and reduce mean time to resolution (MTTR).
|
147
|
-
* Handle CI failures faster by skipping reproduction steps.
|
148
|
-
* Address elusive "Heisenbugs" by capturing error context preemptively.
|
149
|
-
* Debug cron jobs and daemons with rich, failure-specific logs.
|
150
|
-
* LLM-food - Feed debug info with variables into an LLM, making state examine-able for it
|
151
161
|
|
152
162
|
## Installation
|
153
163
|
|
@@ -218,9 +228,6 @@ EnhancedErrors adjusts its default settings based on the environment:
|
|
218
228
|
- **Development/Test**:
|
219
229
|
- Default Output format: `:terminal`
|
220
230
|
- Terminal Color output: Enabled
|
221
|
-
- **Production**:
|
222
|
-
- Output format: `:json`
|
223
|
-
- Terminal Color output: Disabled
|
224
231
|
- **CI Environment**:
|
225
232
|
- Output format: `:plaintext`
|
226
233
|
- Color output: Disabled
|
@@ -332,10 +339,6 @@ These exceptions are always ignored:
|
|
332
339
|
|
333
340
|
```ruby
|
334
341
|
SystemExit NoMemoryError SignalException Interrupt
|
335
|
-
ScriptError LoadError NotImplementedError SyntaxError
|
336
|
-
RSpec::Expectations::ExpectationNotMetError
|
337
|
-
RSpec::Matchers::BuiltIn::RaiseError
|
338
|
-
SystemStackError Psych::BadAlias
|
339
342
|
```
|
340
343
|
|
341
344
|
While this is close to "Things that don't descend from StandardError", it's not exactly that.
|
@@ -429,9 +432,9 @@ To make that work, it has to be able to safely be 'on' ahead of time, and gather
|
|
429
432
|
a way I naturally will retain without requiring extra preparation I obviously didn't know to do.
|
430
433
|
|
431
434
|
- EnhancedErrors won't interrupt CI, but it lets me know what happened _without_ reproduction steps
|
432
|
-
- EnhancedErrors could, theoretically,
|
433
|
-
PII, access, and encryption concerns were
|
434
|
-
|
435
|
+
- EnhancedErrors could, theoretically, be fine in production (if data security, redaction,
|
436
|
+
PII, access, and encryption concerns were addressed). Big list, but another option is to selectively enable targeted capture.
|
437
|
+
The hooks provide a place to handle things of this sort.
|
435
438
|
- Has decent performance characteristics
|
436
439
|
- **Only** becomes active in exception raise/rescue scenarios
|
437
440
|
|
@@ -445,10 +448,13 @@ Exceptions. It operates in a narrow scope--becoming active only when exceptions
|
|
445
448
|
|
446
449
|
- **Small Overhead**: Since TracePoint is only activated during exception raising and rescuing, the performance impact is negligible during normal operation. (Benchmark included)
|
447
450
|
|
448
|
-
- **TBD**: Memory considerations. This does capture data when an exception happens. EnhancedErrors hides under the bed
|
451
|
+
- **TBD**: Memory considerations. This does capture data when an exception happens. EnhancedErrors hides under the bed
|
452
|
+
when it sees the scariest exceptions.
|
449
453
|
|
450
|
-
- **Goal: Production Safety**: The gem is designed to, eventually, be
|
451
|
-
I
|
454
|
+
- **Goal: Production Safety**: The gem is designed to, eventually, be suitable for production use.
|
455
|
+
I might not enable it in production *yet* as it is pretty new. It would require
|
456
|
+
a thoughtful approach (perhaps behind a feature flag, or only capturing targeted exceptions
|
457
|
+
via the eligible for capture feature).
|
452
458
|
|
453
459
|
## Contributing
|
454
460
|
|
@@ -459,3 +465,4 @@ Bug reports and pull requests are welcome on GitHub.
|
|
459
465
|
## License
|
460
466
|
|
461
467
|
The gem is available as open-source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
468
|
+
|
data/benchmark/result.txt
CHANGED
@@ -3,11 +3,9 @@ Result from MacOs, Ruby 3.3.6 for benchmark.rb
|
|
3
3
|
--------------------------------------------
|
4
4
|
|
5
5
|
Cost Exploration
|
6
|
-
|
7
|
-
Baseline 1k (NO EnhancedErrors, tight error raise loop): 0.
|
8
|
-
|
9
|
-
Cost per 100 raised exceptions: 0.56 ms
|
10
|
-
user system total real
|
11
|
-
Stress 1k EnhancedErrors (Tight error raising loop w/ EnhancedErrors): 0.005498 0.000147 0.005645 ( 0.005647)
|
12
|
-
|
6
|
+
user system total real
|
7
|
+
Baseline 1k (NO EnhancedErrors, tight error raise loop): 0.000386 0.000049 0.000435 ( 0.000434)
|
13
8
|
|
9
|
+
user system total real
|
10
|
+
Stress 1k EnhancedErrors (Tight error raising loop w/ EnhancedErrors): 0.007653 0.000241 0.007894 ( 0.007894)
|
11
|
+
Cost per 100 raised exceptions: 0.79 ms
|
data/doc/Enhanced/Colors.html
CHANGED
@@ -381,9 +381,9 @@
|
|
381
381
|
</div>
|
382
382
|
|
383
383
|
<div id="footer">
|
384
|
-
Generated on
|
384
|
+
Generated on Wed Dec 25 13:01:48 2024 by
|
385
385
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
386
|
-
0.9.37 (ruby-3.1
|
386
|
+
0.9.37 (ruby-3.4.1).
|
387
387
|
</div>
|
388
388
|
|
389
389
|
</div>
|
data/doc/Enhanced/Context.html
CHANGED
@@ -273,9 +273,9 @@
|
|
273
273
|
</div>
|
274
274
|
|
275
275
|
<div id="footer">
|
276
|
-
Generated on
|
276
|
+
Generated on Wed Dec 25 13:01:48 2024 by
|
277
277
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
278
|
-
0.9.37 (ruby-3.1
|
278
|
+
0.9.37 (ruby-3.4.1).
|
279
279
|
</div>
|
280
280
|
|
281
281
|
</div>
|
@@ -217,21 +217,15 @@
|
|
217
217
|
18
|
218
218
|
19
|
219
219
|
20
|
220
|
-
21
|
221
|
-
22
|
222
|
-
23
|
223
|
-
24</pre>
|
220
|
+
21</pre>
|
224
221
|
</td>
|
225
222
|
<td>
|
226
223
|
<pre class="code"><span class="info file"># File 'lib/enhanced/exception.rb', line 15</span>
|
227
224
|
|
228
225
|
<span class='kw'>def</span> <span class='id identifier rubyid_captured_variables'>captured_variables</span>
|
229
|
-
<span class='kw'>
|
230
|
-
|
231
|
-
|
232
|
-
<span class='kw'>else</span>
|
233
|
-
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
234
|
-
<span class='kw'>end</span>
|
226
|
+
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_binding_infos'>binding_infos</span><span class='op'>&.</span><span class='id identifier rubyid_any?'>any?</span>
|
227
|
+
<span class='id identifier rubyid_bindings_of_interest'>bindings_of_interest</span> <span class='op'>=</span> <span class='id identifier rubyid_select_binding_infos'>select_binding_infos</span>
|
228
|
+
<span class='const'><span class='object_link'><a href="../EnhancedErrors.html" title="EnhancedErrors (class)">EnhancedErrors</a></span></span><span class='period'>.</span><span class='id identifier rubyid_format'><span class='object_link'><a href="../EnhancedErrors.html#format-class_method" title="EnhancedErrors.format (method)">format</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_bindings_of_interest'>bindings_of_interest</span><span class='rparen'>)</span>
|
235
229
|
<span class='kw'>rescue</span>
|
236
230
|
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
237
231
|
<span class='kw'>end</span></pre>
|
@@ -245,9 +239,9 @@
|
|
245
239
|
</div>
|
246
240
|
|
247
241
|
<div id="footer">
|
248
|
-
Generated on
|
242
|
+
Generated on Wed Dec 25 13:01:48 2024 by
|
249
243
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
250
|
-
0.9.37 (ruby-3.1
|
244
|
+
0.9.37 (ruby-3.4.1).
|
251
245
|
</div>
|
252
246
|
|
253
247
|
</div>
|
@@ -387,9 +387,9 @@
|
|
387
387
|
</div>
|
388
388
|
|
389
389
|
<div id="footer">
|
390
|
-
Generated on
|
390
|
+
Generated on Wed Dec 25 13:01:48 2024 by
|
391
391
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
392
|
-
0.9.37 (ruby-3.1
|
392
|
+
0.9.37 (ruby-3.4.1).
|
393
393
|
</div>
|
394
394
|
|
395
395
|
</div>
|
data/doc/Enhanced.html
CHANGED
@@ -114,9 +114,9 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Wed Dec 25 13:01:48 2024 by
|
118
118
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
|
-
0.9.37 (ruby-3.1
|
119
|
+
0.9.37 (ruby-3.4.1).
|
120
120
|
</div>
|
121
121
|
|
122
122
|
</div>
|