electrodb 2.10.3 → 2.10.4
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/index.d.ts +3 -2
- package/package.json +1 -1
- package/src/entity.js +15 -8
package/index.d.ts
CHANGED
|
@@ -2930,11 +2930,12 @@ export type ParamRecord<Options = ParamOptions> = <P = Record<string, any>>(
|
|
|
2930
2930
|
options?: Options,
|
|
2931
2931
|
) => P;
|
|
2932
2932
|
|
|
2933
|
-
export class ElectroError extends Error {
|
|
2933
|
+
export class ElectroError<E extends Error = Error> extends Error {
|
|
2934
2934
|
readonly name: "ElectroError";
|
|
2935
2935
|
readonly code: number;
|
|
2936
2936
|
readonly date: number;
|
|
2937
2937
|
readonly isElectroError: boolean;
|
|
2938
|
+
readonly cause: E | undefined;
|
|
2938
2939
|
ref: {
|
|
2939
2940
|
readonly code: number;
|
|
2940
2941
|
readonly section: string;
|
|
@@ -2967,7 +2968,7 @@ export interface ElectroValidationErrorFieldReference<T extends Error = Error> {
|
|
|
2967
2968
|
|
|
2968
2969
|
export class ElectroValidationError<
|
|
2969
2970
|
T extends Error = Error,
|
|
2970
|
-
> extends ElectroError {
|
|
2971
|
+
> extends ElectroError<T> {
|
|
2971
2972
|
readonly fields: ReadonlyArray<ElectroValidationErrorFieldReference<T>>;
|
|
2972
2973
|
}
|
|
2973
2974
|
|
package/package.json
CHANGED
package/src/entity.js
CHANGED
|
@@ -494,7 +494,7 @@ class Entity {
|
|
|
494
494
|
async go(method, parameters = {}, config = {}) {
|
|
495
495
|
let stackTrace;
|
|
496
496
|
if (!config.originalErr) {
|
|
497
|
-
stackTrace = new e.ElectroError(e.ErrorCodes.AWSError);
|
|
497
|
+
stackTrace = new e.ElectroError(e.ErrorCodes.AWSError).stack;
|
|
498
498
|
}
|
|
499
499
|
try {
|
|
500
500
|
switch (method) {
|
|
@@ -513,12 +513,13 @@ class Entity {
|
|
|
513
513
|
return Promise.reject(err);
|
|
514
514
|
} else {
|
|
515
515
|
if (err.__isAWSError) {
|
|
516
|
-
|
|
516
|
+
const error = new e.ElectroError(
|
|
517
517
|
e.ErrorCodes.AWSError,
|
|
518
518
|
`Error thrown by DynamoDB client: "${err.message}"`,
|
|
519
519
|
err,
|
|
520
|
-
)
|
|
521
|
-
|
|
520
|
+
);
|
|
521
|
+
error.stack = stackTrace;
|
|
522
|
+
return Promise.reject(error);
|
|
522
523
|
} else if (err.isElectroError) {
|
|
523
524
|
return Promise.reject(err);
|
|
524
525
|
} else {
|
|
@@ -925,7 +926,7 @@ class Entity {
|
|
|
925
926
|
formatResponse(response, index, config = {}) {
|
|
926
927
|
let stackTrace;
|
|
927
928
|
if (!config.originalErr) {
|
|
928
|
-
stackTrace = new e.ElectroError(e.ErrorCodes.AWSError);
|
|
929
|
+
stackTrace = new e.ElectroError(e.ErrorCodes.AWSError).stack;
|
|
929
930
|
}
|
|
930
931
|
try {
|
|
931
932
|
let results = {};
|
|
@@ -1013,11 +1014,17 @@ class Entity {
|
|
|
1013
1014
|
|
|
1014
1015
|
return { data: results };
|
|
1015
1016
|
} catch (err) {
|
|
1016
|
-
if (config.originalErr || stackTrace === undefined) {
|
|
1017
|
+
if (config.originalErr || stackTrace === undefined || err.isElectroError) {
|
|
1017
1018
|
throw err;
|
|
1018
1019
|
} else {
|
|
1019
|
-
|
|
1020
|
-
|
|
1020
|
+
const error = new e.ElectroError(
|
|
1021
|
+
e.ErrorCodes.AWSError,
|
|
1022
|
+
err.message,
|
|
1023
|
+
err,
|
|
1024
|
+
);
|
|
1025
|
+
error.stack = stackTrace;
|
|
1026
|
+
|
|
1027
|
+
throw error;
|
|
1021
1028
|
}
|
|
1022
1029
|
}
|
|
1023
1030
|
}
|