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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcc0ec081a5d0c8971d430b9d87a241c5678d07037a661fc3202b9b5cc416840
4
- data.tar.gz: c136809b9cb0927ec57f95df48a30020875dd0725c6c0efd3983235d8ae2cc82
3
+ metadata.gz: e6463163f60ad8df047c834d0722ebfc800bbb8a9b57773d064b2a22eaeead69
4
+ data.tar.gz: 53c886d04c8b1c518d9a4d05262947f95ba462b9b3cd76cb913c2f2142080a6d
5
5
  SHA512:
6
- metadata.gz: 4d7c0b9e0ae3d02b32442b9a02c9c1b29f35051e2c0c4c9de085a60c11fa7d05b132602ebabfdc438f4721b579deefd561efa13c470324fa5ccd341015eabeee
7
- data.tar.gz: b004525dd0f9dfa3327067b78b3cdf2a9db98bbfa75bd85dc348e220c7ab966d6b8360c0157e8bc23d39a8e8f65219e53c069ad242dda10cf83c5756e96fadf1
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
- RSpec.configure do |config|
45
- config.before(:example) do |_example|
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
- config.after(:example) do |example|
54
- EnhancedErrors.override_rspec_message(example, EnhancedErrors.stop_rspec_binding_capture)
55
- end
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, also be fine in production (if data security, redaction,
433
- PII, access, and encryption concerns were all addressed.
434
- Big list, but another option is to selectively enable targeted capture.
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 when it sees **NoMemoryError**.
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 made safe for production use, giving you valuable insights without compromising performance.
451
- I would not enable it in production *yet*.
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
- user system total real
7
- Baseline 1k (NO EnhancedErrors, tight error raise loop): 0.000296 0.000040 0.000336 ( 0.000334)
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
@@ -381,9 +381,9 @@
381
381
  </div>
382
382
 
383
383
  <div id="footer">
384
- Generated on Tue Dec 24 15:27:20 2024 by
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.3).
386
+ 0.9.37 (ruby-3.4.1).
387
387
  </div>
388
388
 
389
389
  </div>
@@ -273,9 +273,9 @@
273
273
  </div>
274
274
 
275
275
  <div id="footer">
276
- Generated on Tue Dec 24 15:27:20 2024 by
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.3).
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'>if</span> <span class='id identifier rubyid_binding_infos'>binding_infos</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span>
230
- <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>
231
- <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>
232
- <span class='kw'>else</span>
233
- <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
234
- <span class='kw'>end</span>
226
+ <span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_binding_infos'>binding_infos</span><span class='op'>&amp;.</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'>&#39;</span><span class='tstring_end'>&#39;</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 Tue Dec 24 15:27:20 2024 by
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.3).
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 Tue Dec 24 15:27:20 2024 by
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.3).
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 Tue Dec 24 15:27:20 2024 by
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.3).
119
+ 0.9.37 (ruby-3.4.1).
120
120
  </div>
121
121
 
122
122
  </div>