enhanced_errors 2.1.3 → 2.2.0
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 -2
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/doc/Context.html +283 -0
- data/doc/Enhanced/Colors.html +1 -1
- data/doc/Enhanced.html +1 -1
- data/doc/EnhancedErrors.html +63 -61
- data/doc/EnhancedExceptionContext.html +397 -0
- data/doc/Exception.html +9 -139
- data/doc/ExceptionBindingInfos.html +255 -0
- data/doc/Minitest.html +1 -1
- data/doc/_index.html +16 -1
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/method_list.html +84 -36
- data/doc/top-level-namespace.html +3 -3
- data/enhanced_errors.gemspec +1 -1
- data/examples/demo_rspec.rb +0 -4
- data/lib/enhanced/context.rb +7 -0
- data/lib/enhanced/enhanced_exception_context.rb +47 -0
- data/lib/enhanced/exception.rb +15 -5
- data/lib/enhanced_errors.rb +6 -5
- metadata +7 -2
data/doc/method_list.html
CHANGED
@@ -73,23 +73,23 @@
|
|
73
73
|
|
74
74
|
<li class="even ">
|
75
75
|
<div class="item">
|
76
|
-
<span class='object_link'><a href="
|
77
|
-
<small>
|
76
|
+
<span class='object_link'><a href="Context.html#binding_infos-instance_method" title="Context#binding_infos (method)">#binding_infos</a></span>
|
77
|
+
<small>Context</small>
|
78
78
|
</div>
|
79
79
|
</li>
|
80
80
|
|
81
81
|
|
82
82
|
<li class="odd ">
|
83
83
|
<div class="item">
|
84
|
-
<span class='object_link'><a href="
|
85
|
-
<small>
|
84
|
+
<span class='object_link'><a href="ExceptionBindingInfos.html#binding_infos-instance_method" title="ExceptionBindingInfos#binding_infos (method)">#binding_infos</a></span>
|
85
|
+
<small>ExceptionBindingInfos</small>
|
86
86
|
</div>
|
87
87
|
</li>
|
88
88
|
|
89
89
|
|
90
90
|
<li class="even ">
|
91
91
|
<div class="item">
|
92
|
-
<span class='object_link'><a href="EnhancedErrors.html#
|
92
|
+
<span class='object_link'><a href="EnhancedErrors.html#binding_infos_array_to_string-class_method" title="EnhancedErrors.binding_infos_array_to_string (method)">binding_infos_array_to_string</a></span>
|
93
93
|
<small>EnhancedErrors</small>
|
94
94
|
</div>
|
95
95
|
</li>
|
@@ -97,7 +97,7 @@
|
|
97
97
|
|
98
98
|
<li class="odd ">
|
99
99
|
<div class="item">
|
100
|
-
<span class='object_link'><a href="EnhancedErrors.html#capture_events_count
|
100
|
+
<span class='object_link'><a href="EnhancedErrors.html#capture_events_count-class_method" title="EnhancedErrors.capture_events_count (method)">capture_events_count</a></span>
|
101
101
|
<small>EnhancedErrors</small>
|
102
102
|
</div>
|
103
103
|
</li>
|
@@ -105,7 +105,7 @@
|
|
105
105
|
|
106
106
|
<li class="even ">
|
107
107
|
<div class="item">
|
108
|
-
<span class='object_link'><a href="EnhancedErrors.html#
|
108
|
+
<span class='object_link'><a href="EnhancedErrors.html#capture_events_count=-class_method" title="EnhancedErrors.capture_events_count= (method)">capture_events_count=</a></span>
|
109
109
|
<small>EnhancedErrors</small>
|
110
110
|
</div>
|
111
111
|
</li>
|
@@ -113,7 +113,7 @@
|
|
113
113
|
|
114
114
|
<li class="odd ">
|
115
115
|
<div class="item">
|
116
|
-
<span class='object_link'><a href="EnhancedErrors.html#
|
116
|
+
<span class='object_link'><a href="EnhancedErrors.html#capture_limit_exceeded%3F-class_method" title="EnhancedErrors.capture_limit_exceeded? (method)">capture_limit_exceeded?</a></span>
|
117
117
|
<small>EnhancedErrors</small>
|
118
118
|
</div>
|
119
119
|
</li>
|
@@ -121,7 +121,7 @@
|
|
121
121
|
|
122
122
|
<li class="even ">
|
123
123
|
<div class="item">
|
124
|
-
<span class='object_link'><a href="EnhancedErrors.html#capture_rescue
|
124
|
+
<span class='object_link'><a href="EnhancedErrors.html#capture_rescue-class_method" title="EnhancedErrors.capture_rescue (method)">capture_rescue</a></span>
|
125
125
|
<small>EnhancedErrors</small>
|
126
126
|
</div>
|
127
127
|
</li>
|
@@ -129,13 +129,21 @@
|
|
129
129
|
|
130
130
|
<li class="odd ">
|
131
131
|
<div class="item">
|
132
|
-
<span class='object_link'><a href="
|
133
|
-
<small>
|
132
|
+
<span class='object_link'><a href="EnhancedErrors.html#capture_rescue=-class_method" title="EnhancedErrors.capture_rescue= (method)">capture_rescue=</a></span>
|
133
|
+
<small>EnhancedErrors</small>
|
134
134
|
</div>
|
135
135
|
</li>
|
136
136
|
|
137
137
|
|
138
138
|
<li class="even ">
|
139
|
+
<div class="item">
|
140
|
+
<span class='object_link'><a href="ExceptionBindingInfos.html#captured_variables-instance_method" title="ExceptionBindingInfos#captured_variables (method)">#captured_variables</a></span>
|
141
|
+
<small>ExceptionBindingInfos</small>
|
142
|
+
</div>
|
143
|
+
</li>
|
144
|
+
|
145
|
+
|
146
|
+
<li class="odd ">
|
139
147
|
<div class="item">
|
140
148
|
<span class='object_link'><a href="EnhancedErrors.html#class_to_string-class_method" title="EnhancedErrors.class_to_string (method)">class_to_string</a></span>
|
141
149
|
<small>EnhancedErrors</small>
|
@@ -143,7 +151,23 @@
|
|
143
151
|
</li>
|
144
152
|
|
145
153
|
|
154
|
+
<li class="even ">
|
155
|
+
<div class="item">
|
156
|
+
<span class='object_link'><a href="EnhancedExceptionContext.html#clear_all-instance_method" title="EnhancedExceptionContext#clear_all (method)">#clear_all</a></span>
|
157
|
+
<small>EnhancedExceptionContext</small>
|
158
|
+
</div>
|
159
|
+
</li>
|
160
|
+
|
161
|
+
|
146
162
|
<li class="odd ">
|
163
|
+
<div class="item">
|
164
|
+
<span class='object_link'><a href="EnhancedExceptionContext.html#clear_context-instance_method" title="EnhancedExceptionContext#clear_context (method)">#clear_context</a></span>
|
165
|
+
<small>EnhancedExceptionContext</small>
|
166
|
+
</div>
|
167
|
+
</li>
|
168
|
+
|
169
|
+
|
170
|
+
<li class="even ">
|
147
171
|
<div class="item">
|
148
172
|
<span class='object_link'><a href="Enhanced/Colors.html#code-class_method" title="Enhanced::Colors.code (method)">code</a></span>
|
149
173
|
<small>Enhanced::Colors</small>
|
@@ -151,7 +175,7 @@
|
|
151
175
|
</li>
|
152
176
|
|
153
177
|
|
154
|
-
<li class="
|
178
|
+
<li class="odd ">
|
155
179
|
<div class="item">
|
156
180
|
<span class='object_link'><a href="Enhanced/Colors.html#color-class_method" title="Enhanced::Colors.color (method)">color</a></span>
|
157
181
|
<small>Enhanced::Colors</small>
|
@@ -159,7 +183,7 @@
|
|
159
183
|
</li>
|
160
184
|
|
161
185
|
|
162
|
-
<li class="
|
186
|
+
<li class="even ">
|
163
187
|
<div class="item">
|
164
188
|
<span class='object_link'><a href="EnhancedErrors.html#config_block-class_method" title="EnhancedErrors.config_block (method)">config_block</a></span>
|
165
189
|
<small>EnhancedErrors</small>
|
@@ -167,6 +191,14 @@
|
|
167
191
|
</li>
|
168
192
|
|
169
193
|
|
194
|
+
<li class="odd ">
|
195
|
+
<div class="item">
|
196
|
+
<span class='object_link'><a href="EnhancedExceptionContext.html#context_for-instance_method" title="EnhancedExceptionContext#context_for (method)">#context_for</a></span>
|
197
|
+
<small>EnhancedExceptionContext</small>
|
198
|
+
</div>
|
199
|
+
</li>
|
200
|
+
|
201
|
+
|
170
202
|
<li class="even ">
|
171
203
|
<div class="item">
|
172
204
|
<span class='object_link'><a href="EnhancedErrors.html#convert_binding_to_binding_info-class_method" title="EnhancedErrors.convert_binding_to_binding_info (method)">convert_binding_to_binding_info</a></span>
|
@@ -264,6 +296,14 @@
|
|
264
296
|
|
265
297
|
|
266
298
|
<li class="even ">
|
299
|
+
<div class="item">
|
300
|
+
<span class='object_link'><a href="Context.html#initialize-instance_method" title="Context#initialize (method)">#initialize</a></span>
|
301
|
+
<small>Context</small>
|
302
|
+
</div>
|
303
|
+
</li>
|
304
|
+
|
305
|
+
|
306
|
+
<li class="odd ">
|
267
307
|
<div class="item">
|
268
308
|
<span class='object_link'><a href="EnhancedErrors.html#is_a_minitest%3F-class_method" title="EnhancedErrors.is_a_minitest? (method)">is_a_minitest?</a></span>
|
269
309
|
<small>EnhancedErrors</small>
|
@@ -271,7 +311,7 @@
|
|
271
311
|
</li>
|
272
312
|
|
273
313
|
|
274
|
-
<li class="
|
314
|
+
<li class="even ">
|
275
315
|
<div class="item">
|
276
316
|
<span class='object_link'><a href="EnhancedErrors.html#is_rspec_example%3F-class_method" title="EnhancedErrors.is_rspec_example? (method)">is_rspec_example?</a></span>
|
277
317
|
<small>EnhancedErrors</small>
|
@@ -279,7 +319,7 @@
|
|
279
319
|
</li>
|
280
320
|
|
281
321
|
|
282
|
-
<li class="
|
322
|
+
<li class="odd ">
|
283
323
|
<div class="item">
|
284
324
|
<span class='object_link'><a href="EnhancedErrors.html#max_capture_events-class_method" title="EnhancedErrors.max_capture_events (method)">max_capture_events</a></span>
|
285
325
|
<small>EnhancedErrors</small>
|
@@ -287,7 +327,7 @@
|
|
287
327
|
</li>
|
288
328
|
|
289
329
|
|
290
|
-
<li class="
|
330
|
+
<li class="even ">
|
291
331
|
<div class="item">
|
292
332
|
<span class='object_link'><a href="EnhancedErrors.html#max_capture_events=-class_method" title="EnhancedErrors.max_capture_events= (method)">max_capture_events=</a></span>
|
293
333
|
<small>EnhancedErrors</small>
|
@@ -295,7 +335,7 @@
|
|
295
335
|
</li>
|
296
336
|
|
297
337
|
|
298
|
-
<li class="
|
338
|
+
<li class="odd ">
|
299
339
|
<div class="item">
|
300
340
|
<span class='object_link'><a href="EnhancedErrors.html#max_length-class_method" title="EnhancedErrors.max_length (method)">max_length</a></span>
|
301
341
|
<small>EnhancedErrors</small>
|
@@ -303,7 +343,7 @@
|
|
303
343
|
</li>
|
304
344
|
|
305
345
|
|
306
|
-
<li class="
|
346
|
+
<li class="even ">
|
307
347
|
<div class="item">
|
308
348
|
<span class='object_link'><a href="EnhancedErrors.html#mutex-class_method" title="EnhancedErrors.mutex (method)">mutex</a></span>
|
309
349
|
<small>EnhancedErrors</small>
|
@@ -311,7 +351,7 @@
|
|
311
351
|
</li>
|
312
352
|
|
313
353
|
|
314
|
-
<li class="
|
354
|
+
<li class="odd ">
|
315
355
|
<div class="item">
|
316
356
|
<span class='object_link'><a href="EnhancedErrors.html#on_capture-class_method" title="EnhancedErrors.on_capture (method)">on_capture</a></span>
|
317
357
|
<small>EnhancedErrors</small>
|
@@ -319,7 +359,7 @@
|
|
319
359
|
</li>
|
320
360
|
|
321
361
|
|
322
|
-
<li class="
|
362
|
+
<li class="even ">
|
323
363
|
<div class="item">
|
324
364
|
<span class='object_link'><a href="EnhancedErrors.html#on_capture=-class_method" title="EnhancedErrors.on_capture= (method)">on_capture=</a></span>
|
325
365
|
<small>EnhancedErrors</small>
|
@@ -327,7 +367,7 @@
|
|
327
367
|
</li>
|
328
368
|
|
329
369
|
|
330
|
-
<li class="
|
370
|
+
<li class="odd ">
|
331
371
|
<div class="item">
|
332
372
|
<span class='object_link'><a href="EnhancedErrors.html#on_capture_hook-class_method" title="EnhancedErrors.on_capture_hook (method)">on_capture_hook</a></span>
|
333
373
|
<small>EnhancedErrors</small>
|
@@ -335,7 +375,7 @@
|
|
335
375
|
</li>
|
336
376
|
|
337
377
|
|
338
|
-
<li class="
|
378
|
+
<li class="even ">
|
339
379
|
<div class="item">
|
340
380
|
<span class='object_link'><a href="EnhancedErrors.html#on_format-class_method" title="EnhancedErrors.on_format (method)">on_format</a></span>
|
341
381
|
<small>EnhancedErrors</small>
|
@@ -343,7 +383,7 @@
|
|
343
383
|
</li>
|
344
384
|
|
345
385
|
|
346
|
-
<li class="
|
386
|
+
<li class="odd ">
|
347
387
|
<div class="item">
|
348
388
|
<span class='object_link'><a href="EnhancedErrors.html#on_format=-class_method" title="EnhancedErrors.on_format= (method)">on_format=</a></span>
|
349
389
|
<small>EnhancedErrors</small>
|
@@ -351,7 +391,7 @@
|
|
351
391
|
</li>
|
352
392
|
|
353
393
|
|
354
|
-
<li class="
|
394
|
+
<li class="even ">
|
355
395
|
<div class="item">
|
356
396
|
<span class='object_link'><a href="Minitest.html#original_run_one_method-class_method" title="Minitest.original_run_one_method (method)">original_run_one_method</a></span>
|
357
397
|
<small>Minitest</small>
|
@@ -359,7 +399,7 @@
|
|
359
399
|
</li>
|
360
400
|
|
361
401
|
|
362
|
-
<li class="
|
402
|
+
<li class="odd ">
|
363
403
|
<div class="item">
|
364
404
|
<span class='object_link'><a href="EnhancedErrors.html#override_exception_message-class_method" title="EnhancedErrors.override_exception_message (method)">override_exception_message</a></span>
|
365
405
|
<small>EnhancedErrors</small>
|
@@ -367,7 +407,7 @@
|
|
367
407
|
</li>
|
368
408
|
|
369
409
|
|
370
|
-
<li class="
|
410
|
+
<li class="even ">
|
371
411
|
<div class="item">
|
372
412
|
<span class='object_link'><a href="EnhancedErrors.html#override_messages-class_method" title="EnhancedErrors.override_messages (method)">override_messages</a></span>
|
373
413
|
<small>EnhancedErrors</small>
|
@@ -375,7 +415,7 @@
|
|
375
415
|
</li>
|
376
416
|
|
377
417
|
|
378
|
-
<li class="
|
418
|
+
<li class="odd ">
|
379
419
|
<div class="item">
|
380
420
|
<span class='object_link'><a href="EnhancedErrors.html#override_rspec_message-class_method" title="EnhancedErrors.override_rspec_message (method)">override_rspec_message</a></span>
|
381
421
|
<small>EnhancedErrors</small>
|
@@ -383,7 +423,7 @@
|
|
383
423
|
</li>
|
384
424
|
|
385
425
|
|
386
|
-
<li class="
|
426
|
+
<li class="even ">
|
387
427
|
<div class="item">
|
388
428
|
<span class='object_link'><a href="EnhancedErrors.html#reset!-class_method" title="EnhancedErrors.reset! (method)">reset!</a></span>
|
389
429
|
<small>EnhancedErrors</small>
|
@@ -391,7 +431,7 @@
|
|
391
431
|
</li>
|
392
432
|
|
393
433
|
|
394
|
-
<li class="
|
434
|
+
<li class="odd ">
|
395
435
|
<div class="item">
|
396
436
|
<span class='object_link'><a href="Minitest.html#run_one_method-class_method" title="Minitest.run_one_method (method)">run_one_method</a></span>
|
397
437
|
<small>Minitest</small>
|
@@ -399,7 +439,7 @@
|
|
399
439
|
</li>
|
400
440
|
|
401
441
|
|
402
|
-
<li class="
|
442
|
+
<li class="even ">
|
403
443
|
<div class="item">
|
404
444
|
<span class='object_link'><a href="EnhancedErrors.html#running_in_ci%3F-class_method" title="EnhancedErrors.running_in_ci? (method)">running_in_ci?</a></span>
|
405
445
|
<small>EnhancedErrors</small>
|
@@ -407,7 +447,7 @@
|
|
407
447
|
</li>
|
408
448
|
|
409
449
|
|
410
|
-
<li class="
|
450
|
+
<li class="odd ">
|
411
451
|
<div class="item">
|
412
452
|
<span class='object_link'><a href="EnhancedErrors.html#safe_prepend_module-class_method" title="EnhancedErrors.safe_prepend_module (method)">safe_prepend_module</a></span>
|
413
453
|
<small>EnhancedErrors</small>
|
@@ -415,7 +455,7 @@
|
|
415
455
|
</li>
|
416
456
|
|
417
457
|
|
418
|
-
<li class="
|
458
|
+
<li class="even ">
|
419
459
|
<div class="item">
|
420
460
|
<span class='object_link'><a href="EnhancedErrors.html#skip_list-class_method" title="EnhancedErrors.skip_list (method)">skip_list</a></span>
|
421
461
|
<small>EnhancedErrors</small>
|
@@ -423,7 +463,7 @@
|
|
423
463
|
</li>
|
424
464
|
|
425
465
|
|
426
|
-
<li class="
|
466
|
+
<li class="odd ">
|
427
467
|
<div class="item">
|
428
468
|
<span class='object_link'><a href="EnhancedErrors.html#start_minitest_binding_capture-class_method" title="EnhancedErrors.start_minitest_binding_capture (method)">start_minitest_binding_capture</a></span>
|
429
469
|
<small>EnhancedErrors</small>
|
@@ -431,7 +471,7 @@
|
|
431
471
|
</li>
|
432
472
|
|
433
473
|
|
434
|
-
<li class="
|
474
|
+
<li class="even ">
|
435
475
|
<div class="item">
|
436
476
|
<span class='object_link'><a href="EnhancedErrors.html#start_rspec_binding_capture-class_method" title="EnhancedErrors.start_rspec_binding_capture (method)">start_rspec_binding_capture</a></span>
|
437
477
|
<small>EnhancedErrors</small>
|
@@ -439,7 +479,7 @@
|
|
439
479
|
</li>
|
440
480
|
|
441
481
|
|
442
|
-
<li class="
|
482
|
+
<li class="odd ">
|
443
483
|
<div class="item">
|
444
484
|
<span class='object_link'><a href="EnhancedErrors.html#stop_minitest_binding_capture-class_method" title="EnhancedErrors.stop_minitest_binding_capture (method)">stop_minitest_binding_capture</a></span>
|
445
485
|
<small>EnhancedErrors</small>
|
@@ -447,7 +487,7 @@
|
|
447
487
|
</li>
|
448
488
|
|
449
489
|
|
450
|
-
<li class="
|
490
|
+
<li class="even ">
|
451
491
|
<div class="item">
|
452
492
|
<span class='object_link'><a href="EnhancedErrors.html#stop_rspec_binding_capture-class_method" title="EnhancedErrors.stop_rspec_binding_capture (method)">stop_rspec_binding_capture</a></span>
|
453
493
|
<small>EnhancedErrors</small>
|
@@ -455,6 +495,14 @@
|
|
455
495
|
</li>
|
456
496
|
|
457
497
|
|
498
|
+
<li class="odd ">
|
499
|
+
<div class="item">
|
500
|
+
<span class='object_link'><a href="EnhancedExceptionContext.html#store_context-instance_method" title="EnhancedExceptionContext#store_context (method)">#store_context</a></span>
|
501
|
+
<small>EnhancedExceptionContext</small>
|
502
|
+
</div>
|
503
|
+
</li>
|
504
|
+
|
505
|
+
|
458
506
|
<li class="even ">
|
459
507
|
<div class="item">
|
460
508
|
<span class='object_link'><a href="EnhancedErrors.html#validate_binding_format-class_method" title="EnhancedErrors.validate_binding_format (method)">validate_binding_format</a></span>
|
@@ -82,11 +82,11 @@
|
|
82
82
|
<p class="children">
|
83
83
|
|
84
84
|
|
85
|
-
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Enhanced.html" title="Enhanced (module)">Enhanced</a></span>, <span class='object_link'><a href="Minitest.html" title="Minitest (module)">Minitest</a></span>
|
85
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Enhanced.html" title="Enhanced (module)">Enhanced</a></span>, <span class='object_link'><a href="EnhancedExceptionContext.html" title="EnhancedExceptionContext (module)">EnhancedExceptionContext</a></span>, <span class='object_link'><a href="ExceptionBindingInfos.html" title="ExceptionBindingInfos (module)">ExceptionBindingInfos</a></span>, <span class='object_link'><a href="Minitest.html" title="Minitest (module)">Minitest</a></span>
|
86
86
|
|
87
87
|
|
88
88
|
|
89
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="EnhancedErrors.html" title="EnhancedErrors (class)">EnhancedErrors</a></span>, <span class='object_link'><a href="Exception.html" title="Exception (class)">Exception</a></span>
|
89
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Context.html" title="Context (class)">Context</a></span>, <span class='object_link'><a href="EnhancedErrors.html" title="EnhancedErrors (class)">EnhancedErrors</a></span>, <span class='object_link'><a href="Exception.html" title="Exception (class)">Exception</a></span>
|
90
90
|
|
91
91
|
|
92
92
|
</p>
|
@@ -122,7 +122,7 @@
|
|
122
122
|
</div>
|
123
123
|
|
124
124
|
<div id="footer">
|
125
|
-
Generated on
|
125
|
+
Generated on Tue Dec 17 14:09:26 2024 by
|
126
126
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
127
127
|
0.9.37 (ruby-3.3.6).
|
128
128
|
</div>
|
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 = "2.
|
3
|
+
spec.version = "2.2.0"
|
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/examples/demo_rspec.rb
CHANGED
@@ -14,10 +14,6 @@ RSpec.configure do |config|
|
|
14
14
|
EnhancedErrors.start_rspec_binding_capture
|
15
15
|
end
|
16
16
|
|
17
|
-
config.before(:example) do |_example|
|
18
|
-
EnhancedErrors.start_rspec_binding_capture
|
19
|
-
end
|
20
|
-
|
21
17
|
config.after(:example) do |example|
|
22
18
|
EnhancedErrors.override_rspec_message(example, EnhancedErrors.stop_rspec_binding_capture)
|
23
19
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'weakref'
|
2
|
+
|
3
|
+
require_relative 'context'
|
4
|
+
|
5
|
+
require 'weakref'
|
6
|
+
require 'monitor'
|
7
|
+
|
8
|
+
module EnhancedExceptionContext
|
9
|
+
extend self
|
10
|
+
|
11
|
+
REGISTRY = {}
|
12
|
+
MUTEX = Monitor.new
|
13
|
+
|
14
|
+
def store_context(exception, context)
|
15
|
+
MUTEX.synchronize do
|
16
|
+
REGISTRY[exception.object_id] = { weak_exc: WeakRef.new(exception), context: context }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def context_for(exception)
|
21
|
+
MUTEX.synchronize do
|
22
|
+
entry = REGISTRY[exception.object_id]
|
23
|
+
return nil unless entry
|
24
|
+
|
25
|
+
begin
|
26
|
+
_ = entry[:weak_exc].__getobj__ # ensure exception is still alive
|
27
|
+
entry[:context]
|
28
|
+
rescue RefError
|
29
|
+
# Exception no longer alive, clean up
|
30
|
+
REGISTRY.delete(exception.object_id)
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def clear_context(exception)
|
37
|
+
MUTEX.synchronize do
|
38
|
+
REGISTRY.delete(exception.object_id)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def clear_all
|
43
|
+
MUTEX.synchronize do
|
44
|
+
REGISTRY.clear
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/enhanced/exception.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# exception.rb
|
2
|
+
require_relative 'enhanced_exception_context'
|
3
|
+
|
4
|
+
module ExceptionBindingInfos
|
5
|
+
def binding_infos
|
6
|
+
ctx = EnhancedExceptionContext.context_for(self)
|
7
|
+
unless ctx
|
8
|
+
ctx = Context.new
|
9
|
+
EnhancedExceptionContext.store_context(self, ctx)
|
10
|
+
end
|
11
|
+
ctx.binding_infos
|
12
|
+
end
|
2
13
|
|
3
|
-
class Exception
|
4
14
|
def captured_variables
|
5
15
|
if binding_infos.any?
|
6
16
|
bindings_of_interest = select_binding_infos
|
@@ -12,10 +22,6 @@ class Exception
|
|
12
22
|
''
|
13
23
|
end
|
14
24
|
|
15
|
-
def binding_infos
|
16
|
-
@binding_infos ||= []
|
17
|
-
end
|
18
|
-
|
19
25
|
private
|
20
26
|
|
21
27
|
def select_binding_infos
|
@@ -43,3 +49,7 @@ class Exception
|
|
43
49
|
bindings_of_interest.compact
|
44
50
|
end
|
45
51
|
end
|
52
|
+
|
53
|
+
class Exception
|
54
|
+
prepend ExceptionBindingInfos
|
55
|
+
end
|
data/lib/enhanced_errors.rb
CHANGED
@@ -202,15 +202,16 @@ class EnhancedErrors
|
|
202
202
|
when nil
|
203
203
|
return nil
|
204
204
|
when RSpec::Core::MultipleExceptionError
|
205
|
-
|
205
|
+
exception_obj.all_exceptions.each do |exception|
|
206
|
+
override_exception_message(exception, binding_or_bindings)
|
207
|
+
end
|
206
208
|
else
|
207
209
|
override_exception_message(exception_obj, binding_or_bindings)
|
208
210
|
end
|
209
|
-
|
210
211
|
end
|
211
212
|
|
212
213
|
def override_exception_message(exception, binding_or_bindings)
|
213
|
-
return nil unless exception
|
214
|
+
return nil unless exception && exception.respond_to?(:message)
|
214
215
|
rspec_binding = !(binding_or_bindings.nil? || binding_or_bindings.empty?)
|
215
216
|
exception_binding = (exception.binding_infos.length > 0)
|
216
217
|
has_message = !(exception.respond_to?(:unaltered_message))
|
@@ -225,7 +226,6 @@ class EnhancedErrors
|
|
225
226
|
exception.define_singleton_method(:message) do
|
226
227
|
"#{message_str}#{variable_str}"
|
227
228
|
end
|
228
|
-
exception
|
229
229
|
end
|
230
230
|
|
231
231
|
def add_to_skip_list(*vars)
|
@@ -304,6 +304,7 @@ class EnhancedErrors
|
|
304
304
|
end
|
305
305
|
|
306
306
|
def start_minitest_binding_capture
|
307
|
+
EnhancedExceptionContext.clear_all
|
307
308
|
return if enforce_capture_limit
|
308
309
|
@enabled = true if @enabled.nil?
|
309
310
|
mutex.synchronize do
|
@@ -385,7 +386,7 @@ class EnhancedErrors
|
|
385
386
|
binding_info = convert_binding_to_binding_info(@rspec_example_binding) if @rspec_example_binding
|
386
387
|
@capture_next_binding = false
|
387
388
|
@rspec_example_binding = nil
|
388
|
-
binding_info
|
389
|
+
return binding_info
|
389
390
|
end
|
390
391
|
end
|
391
392
|
|
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: 2.
|
4
|
+
version: 2.2.0
|
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-12-
|
11
|
+
date: 2024-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -84,12 +84,15 @@ files:
|
|
84
84
|
- benchmark/benchmark.rb
|
85
85
|
- benchmark/memory_bench.rb
|
86
86
|
- benchmark/stackprofile.rb
|
87
|
+
- doc/Context.html
|
87
88
|
- doc/Enhanced.html
|
88
89
|
- doc/Enhanced/Colors.html
|
89
90
|
- doc/Enhanced/Integrations.html
|
90
91
|
- doc/Enhanced/Integrations/RSpecErrorFailureMessage.html
|
91
92
|
- doc/EnhancedErrors.html
|
93
|
+
- doc/EnhancedExceptionContext.html
|
92
94
|
- doc/Exception.html
|
95
|
+
- doc/ExceptionBindingInfos.html
|
93
96
|
- doc/Minitest.html
|
94
97
|
- doc/_index.html
|
95
98
|
- doc/class_list.html
|
@@ -113,6 +116,8 @@ files:
|
|
113
116
|
- examples/demo_minitest.rb
|
114
117
|
- examples/demo_rspec.rb
|
115
118
|
- lib/enhanced/colors.rb
|
119
|
+
- lib/enhanced/context.rb
|
120
|
+
- lib/enhanced/enhanced_exception_context.rb
|
116
121
|
- lib/enhanced/exception.rb
|
117
122
|
- lib/enhanced/minitest_patch.rb
|
118
123
|
- lib/enhanced_errors.rb
|