mol_mutable 0.0.789 → 0.0.790
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
|
@@ -345,17 +345,36 @@ var $;
|
|
|
345
345
|
"use strict";
|
|
346
346
|
var $;
|
|
347
347
|
(function ($) {
|
|
348
|
+
function cause_serialize(cause) {
|
|
349
|
+
return JSON.stringify(cause, null, ' ')
|
|
350
|
+
.replace(/\(/, '<')
|
|
351
|
+
.replace(/\)/, ' >');
|
|
352
|
+
}
|
|
353
|
+
function frame_normalize(frame) {
|
|
354
|
+
return (typeof frame === 'string' ? frame : cause_serialize(frame))
|
|
355
|
+
.trim()
|
|
356
|
+
.replace(/at /gm, ' at ')
|
|
357
|
+
.replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
|
|
358
|
+
}
|
|
348
359
|
class $mol_error_mix extends AggregateError {
|
|
349
360
|
cause;
|
|
350
361
|
name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
|
|
351
362
|
constructor(message, cause = {}, ...errors) {
|
|
352
363
|
super(errors, message, { cause });
|
|
353
364
|
this.cause = cause;
|
|
354
|
-
const
|
|
365
|
+
const desc = Object.getOwnPropertyDescriptor(this, 'stack');
|
|
366
|
+
const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
|
|
355
367
|
Object.defineProperty(this, 'stack', {
|
|
356
|
-
get: () =>
|
|
357
|
-
.
|
|
358
|
-
.
|
|
368
|
+
get: () => stack_get() + '\n' + [
|
|
369
|
+
this.cause ?? 'no cause',
|
|
370
|
+
...this.errors.flatMap(e => [
|
|
371
|
+
e.stack,
|
|
372
|
+
...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
|
|
373
|
+
])
|
|
374
|
+
].map(frame_normalize).join('\n')
|
|
375
|
+
});
|
|
376
|
+
Object.defineProperty(this, 'cause', {
|
|
377
|
+
get: () => cause
|
|
359
378
|
});
|
|
360
379
|
}
|
|
361
380
|
static [Symbol.toPrimitive]() {
|