hyoo_sync_client 0.0.595 → 0.0.597

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