mol_key 0.0.1130 → 0.0.1131
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
|
@@ -1431,17 +1431,36 @@ var $;
|
|
|
1431
1431
|
"use strict";
|
|
1432
1432
|
var $;
|
|
1433
1433
|
(function ($) {
|
|
1434
|
+
function cause_serialize(cause) {
|
|
1435
|
+
return JSON.stringify(cause, null, ' ')
|
|
1436
|
+
.replace(/\(/, '<')
|
|
1437
|
+
.replace(/\)/, ' >');
|
|
1438
|
+
}
|
|
1439
|
+
function frame_normalize(frame) {
|
|
1440
|
+
return (typeof frame === 'string' ? frame : cause_serialize(frame))
|
|
1441
|
+
.trim()
|
|
1442
|
+
.replace(/at /gm, ' at ')
|
|
1443
|
+
.replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
|
|
1444
|
+
}
|
|
1434
1445
|
class $mol_error_mix extends AggregateError {
|
|
1435
1446
|
cause;
|
|
1436
1447
|
name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
|
|
1437
1448
|
constructor(message, cause = {}, ...errors) {
|
|
1438
1449
|
super(errors, message, { cause });
|
|
1439
1450
|
this.cause = cause;
|
|
1440
|
-
const
|
|
1451
|
+
const desc = Object.getOwnPropertyDescriptor(this, 'stack');
|
|
1452
|
+
const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
|
|
1441
1453
|
Object.defineProperty(this, 'stack', {
|
|
1442
|
-
get: () =>
|
|
1443
|
-
.
|
|
1444
|
-
.
|
|
1454
|
+
get: () => stack_get() + '\n' + [
|
|
1455
|
+
this.cause ?? 'no cause',
|
|
1456
|
+
...this.errors.flatMap(e => [
|
|
1457
|
+
e.stack,
|
|
1458
|
+
...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
|
|
1459
|
+
])
|
|
1460
|
+
].map(frame_normalize).join('\n')
|
|
1461
|
+
});
|
|
1462
|
+
Object.defineProperty(this, 'cause', {
|
|
1463
|
+
get: () => cause
|
|
1445
1464
|
});
|
|
1446
1465
|
}
|
|
1447
1466
|
static [Symbol.toPrimitive]() {
|