mol_regexp 0.0.1408 → 0.0.1409
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.
- package/node.test.js +23 -4
- package/node.test.js.map +1 -1
- package/package.json +1 -1
package/node.test.js
CHANGED
|
@@ -610,17 +610,36 @@ var $;
|
|
|
610
610
|
"use strict";
|
|
611
611
|
var $;
|
|
612
612
|
(function ($) {
|
|
613
|
+
function cause_serialize(cause) {
|
|
614
|
+
return JSON.stringify(cause, null, ' ')
|
|
615
|
+
.replace(/\(/, '<')
|
|
616
|
+
.replace(/\)/, ' >');
|
|
617
|
+
}
|
|
618
|
+
function frame_normalize(frame) {
|
|
619
|
+
return (typeof frame === 'string' ? frame : cause_serialize(frame))
|
|
620
|
+
.trim()
|
|
621
|
+
.replace(/at /gm, ' at ')
|
|
622
|
+
.replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
|
|
623
|
+
}
|
|
613
624
|
class $mol_error_mix extends AggregateError {
|
|
614
625
|
cause;
|
|
615
626
|
name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
|
|
616
627
|
constructor(message, cause = {}, ...errors) {
|
|
617
628
|
super(errors, message, { cause });
|
|
618
629
|
this.cause = cause;
|
|
619
|
-
const
|
|
630
|
+
const desc = Object.getOwnPropertyDescriptor(this, 'stack');
|
|
631
|
+
const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
|
|
620
632
|
Object.defineProperty(this, 'stack', {
|
|
621
|
-
get: () =>
|
|
622
|
-
.
|
|
623
|
-
.
|
|
633
|
+
get: () => stack_get() + '\n' + [
|
|
634
|
+
this.cause ?? 'no cause',
|
|
635
|
+
...this.errors.flatMap(e => [
|
|
636
|
+
e.stack,
|
|
637
|
+
...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
|
|
638
|
+
])
|
|
639
|
+
].map(frame_normalize).join('\n')
|
|
640
|
+
});
|
|
641
|
+
Object.defineProperty(this, 'cause', {
|
|
642
|
+
get: () => cause
|
|
624
643
|
});
|
|
625
644
|
}
|
|
626
645
|
static [Symbol.toPrimitive]() {
|