hyoo_sync_client 0.0.352 → 0.0.354
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.d.ts +3 -6
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +5 -23
- package/node.js.map +1 -1
- package/node.mjs +5 -23
- package/node.test.js +24 -52
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +3 -6
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +9 -23
- package/web.js.map +1 -1
- package/web.mjs +9 -23
- package/web.test.js +19 -29
- package/web.test.js.map +1 -1
package/web.mjs
CHANGED
|
@@ -347,28 +347,15 @@ var $;
|
|
|
347
347
|
var $;
|
|
348
348
|
(function ($) {
|
|
349
349
|
class $mol_error_mix extends AggregateError {
|
|
350
|
-
|
|
351
|
-
constructor(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
pick(Class) {
|
|
361
|
-
if (this instanceof Class)
|
|
362
|
-
return this;
|
|
363
|
-
for (const e of this.errors) {
|
|
364
|
-
if (e instanceof Class)
|
|
365
|
-
return e;
|
|
366
|
-
}
|
|
367
|
-
for (const e of this.cause) {
|
|
368
|
-
if (e && e instanceof Class)
|
|
369
|
-
return e;
|
|
370
|
-
}
|
|
371
|
-
return null;
|
|
350
|
+
cause;
|
|
351
|
+
name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
|
|
352
|
+
constructor(message, cause, ...errors) {
|
|
353
|
+
super(errors, message, { cause });
|
|
354
|
+
this.cause = cause;
|
|
355
|
+
const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
|
|
356
|
+
Object.defineProperty(this, 'stack', {
|
|
357
|
+
get: () => stack_get.call(this) + '\n' + this.errors.map(e => e.stack.trim().replace(/at /gm, ' at ').replace(/^(?! )(.*)/gm, ' at [$1] (#)')).join('\n')
|
|
358
|
+
});
|
|
372
359
|
}
|
|
373
360
|
}
|
|
374
361
|
$.$mol_error_mix = $mol_error_mix;
|
|
@@ -379,7 +366,6 @@ var $;
|
|
|
379
366
|
var $;
|
|
380
367
|
(function ($) {
|
|
381
368
|
class $mol_data_error extends $mol_error_mix {
|
|
382
|
-
name = '$mol_data_error';
|
|
383
369
|
}
|
|
384
370
|
$.$mol_data_error = $mol_data_error;
|
|
385
371
|
})($ || ($ = {}));
|
package/web.test.js
CHANGED
|
@@ -853,39 +853,29 @@ var $;
|
|
|
853
853
|
(function ($) {
|
|
854
854
|
$mol_test({
|
|
855
855
|
'auto name'() {
|
|
856
|
-
class
|
|
856
|
+
class Invalid extends $mol_error_mix {
|
|
857
857
|
}
|
|
858
|
-
const mix = new
|
|
859
|
-
$mol_assert_equal(mix.name, '
|
|
858
|
+
const mix = new Invalid('foo');
|
|
859
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
860
860
|
},
|
|
861
|
-
'
|
|
862
|
-
const mix = new $mol_error_mix('foo');
|
|
861
|
+
'simpe mix'() {
|
|
862
|
+
const mix = new $mol_error_mix('foo', null, new Error('bar'), new Error('lol'));
|
|
863
863
|
$mol_assert_equal(mix.message, 'foo');
|
|
864
|
-
$mol_assert_equal(mix.
|
|
864
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
865
865
|
},
|
|
866
|
-
'
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
$
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
new SyntaxError('xxx1'),
|
|
880
|
-
new SyntaxError('xxx2'),
|
|
881
|
-
new TypeError('lol0'),
|
|
882
|
-
],
|
|
883
|
-
}), new TypeError('lol1', {
|
|
884
|
-
cause: new TypeError('xxx3'),
|
|
885
|
-
}), new TypeError('lol2'));
|
|
886
|
-
$mol_assert_equal(mix.pick(RangeError).message, 'bar');
|
|
887
|
-
$mol_assert_equal(mix.pick(SyntaxError).message, 'xxx1');
|
|
888
|
-
$mol_assert_equal(mix.pick(TypeError).message, 'lol1');
|
|
866
|
+
'provide additional info'() {
|
|
867
|
+
class Invalid extends $mol_error_mix {
|
|
868
|
+
}
|
|
869
|
+
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' }));
|
|
870
|
+
const hints = [];
|
|
871
|
+
if (mix instanceof $mol_error_mix) {
|
|
872
|
+
for (const er of mix.errors) {
|
|
873
|
+
if (er instanceof Invalid) {
|
|
874
|
+
hints.push(er.cause?.hint ?? '');
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
889
879
|
},
|
|
890
880
|
});
|
|
891
881
|
})($ || ($ = {}));
|