@@ -397,7 +397,7 @@ export function dehydrate(
397
397
return object ;
398
398
}
399
399
400
- case 'class_instance' :
400
+ case 'class_instance' : {
401
401
isPathAllowedCheck = isPathAllowed ( path ) ;
402
402
403
403
if ( level >= LEVEL_THRESHOLD && ! isPathAllowedCheck ) {
@@ -433,7 +433,69 @@ export function dehydrate(
433
433
unserializable . push ( path ) ;
434
434
435
435
return value ;
436
+ }
437
+ case 'error ': {
438
+ isPathAllowedCheck = isPathAllowed ( path ) ;
439
+
440
+ if ( level >= LEVEL_THRESHOLD && ! isPathAllowedCheck ) {
441
+ return createDehydrated ( type , true , data , cleaned , path ) ;
442
+ }
443
+
444
+ const value : Unserializable = {
445
+ unserializable : true ,
446
+ type ,
447
+ readonly : true ,
448
+ preview_short : formatDataForPreview ( data , false ) ,
449
+ preview_long : formatDataForPreview ( data , true ) ,
450
+ name : data . name ,
451
+ } ;
452
+
453
+ // name, message, stack and cause are not enumerable yet still interesting.
454
+ value . message = dehydrate (
455
+ data . message ,
456
+ cleaned ,
457
+ unserializable ,
458
+ path . concat ( [ 'message' ] ) ,
459
+ isPathAllowed ,
460
+ isPathAllowedCheck ? 1 : level + 1 ,
461
+ ) ;
462
+ value . stack = dehydrate (
463
+ data . stack ,
464
+ cleaned ,
465
+ unserializable ,
466
+ path . concat ( [ 'stack' ] ) ,
467
+ isPathAllowed ,
468
+ isPathAllowedCheck ? 1 : level + 1 ,
469
+ ) ;
470
+
471
+ if ( 'cause' in data ) {
472
+ value . cause = dehydrate (
473
+ data . cause ,
474
+ cleaned ,
475
+ unserializable ,
476
+ path . concat ( [ 'cause' ] ) ,
477
+ isPathAllowed ,
478
+ isPathAllowedCheck ? 1 : level + 1 ,
479
+ ) ;
480
+ }
481
+
482
+ getAllEnumerableKeys ( data ) . forEach ( key => {
483
+ const keyAsString = key . toString ( ) ;
436
484
485
+ value [ keyAsString ] = dehydrate (
486
+ data [ key ] ,
487
+ cleaned ,
488
+ unserializable ,
489
+ path . concat ( [ keyAsString ] ) ,
490
+ isPathAllowed ,
491
+ isPathAllowedCheck ? 1 : level + 1 ,
492
+ ) ;
493
+ } ) ;
494
+
495
+ unserializable . push ( path ) ;
496
+
497
+ return value ;
498
+ }
437
499
case 'infinity ':
438
500
case 'nan ':
439
501
case 'undefined ':
0 commit comments