hyoo_sync_client 0.0.595 → 0.0.596

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