hyoo_sync_client 0.0.354 → 0.0.356

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
@@ -884,8 +884,9 @@ var $;
884
884
  shell: true,
885
885
  env: this.$mol_env(),
886
886
  });
887
- if (res.status || res.error)
888
- return $mol_fail(res.error || new Error(res.stderr.toString()));
887
+ if (res.status || res.error) {
888
+ return $mol_fail(res.error || new Error(res.stderr.toString(), { cause: res.stdout }));
889
+ }
889
890
  if (!res.stdout)
890
891
  res.stdout = Buffer.from([]);
891
892
  return res;
@@ -998,9 +999,15 @@ var $;
998
999
  class $mol_error_mix extends AggregateError {
999
1000
  cause;
1000
1001
  name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
1001
- constructor(message, cause, ...errors) {
1002
+ constructor(message, cause = {}, ...errors) {
1002
1003
  super(errors, message, { cause });
1003
1004
  this.cause = cause;
1005
+ const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
1006
+ Object.defineProperty(this, 'stack', {
1007
+ get: () => stack_get.call(this) + '\n' + [JSON.stringify(this.cause, null, ' ') ?? 'no cause', ...this.errors.map(e => e.stack)].map(e => e.trim()
1008
+ .replace(/at /gm, ' at ')
1009
+ .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
1010
+ });
1004
1011
  }
1005
1012
  }
1006
1013
  $.$mol_error_mix = $mol_error_mix;
package/node.test.js CHANGED
@@ -875,8 +875,9 @@ var $;
875
875
  shell: true,
876
876
  env: this.$mol_env(),
877
877
  });
878
- if (res.status || res.error)
879
- return $mol_fail(res.error || new Error(res.stderr.toString()));
878
+ if (res.status || res.error) {
879
+ return $mol_fail(res.error || new Error(res.stderr.toString(), { cause: res.stdout }));
880
+ }
880
881
  if (!res.stdout)
881
882
  res.stdout = Buffer.from([]);
882
883
  return res;
@@ -989,9 +990,15 @@ var $;
989
990
  class $mol_error_mix extends AggregateError {
990
991
  cause;
991
992
  name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
992
- constructor(message, cause, ...errors) {
993
+ constructor(message, cause = {}, ...errors) {
993
994
  super(errors, message, { cause });
994
995
  this.cause = cause;
996
+ const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
997
+ Object.defineProperty(this, 'stack', {
998
+ get: () => stack_get.call(this) + '\n' + [JSON.stringify(this.cause, null, ' ') ?? 'no cause', ...this.errors.map(e => e.stack)].map(e => e.trim()
999
+ .replace(/at /gm, ' at ')
1000
+ .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
1001
+ });
995
1002
  }
996
1003
  }
997
1004
  $.$mol_error_mix = $mol_error_mix;
@@ -5652,14 +5659,14 @@ var $;
5652
5659
  $mol_assert_equal(mix.name, 'Invalid_Error');
5653
5660
  },
5654
5661
  'simpe mix'() {
5655
- const mix = new $mol_error_mix('foo', null, new Error('bar'), new Error('lol'));
5662
+ const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
5656
5663
  $mol_assert_equal(mix.message, 'foo');
5657
5664
  $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
5658
5665
  },
5659
5666
  'provide additional info'() {
5660
5667
  class Invalid extends $mol_error_mix {
5661
5668
  }
5662
- const mix = new $mol_error_mix('Wrong password', null, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
5669
+ const mix = new $mol_error_mix('Wrong password', {}, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
5663
5670
  const hints = [];
5664
5671
  if (mix instanceof $mol_error_mix) {
5665
5672
  for (const er of mix.errors) {