Skip to content

Commit

Permalink
fix: update error messge to NumberValue (#6579)
Browse files Browse the repository at this point in the history
* fix: update error message to NumberValue

---------

Co-authored-by: George Fu <[email protected]>
  • Loading branch information
zshzbh and kuhe authored Oct 22, 2024
1 parent 25443cc commit 1902196
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/util-dynamodb/src/convertToAttr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ describe("convertToAttr", () => {

expect(() => {
convertToAttr(num, { convertClassInstanceToMap });
}).toThrowError(`${errorPrefix} Use BigInt.`);
}).toThrowError(`${errorPrefix} Use NumberValue from @aws-sdk/lib-dynamodb.`);

const BigIntConstructor = BigInt;
(BigInt as any) = undefined;
expect(() => {
convertToAttr(num, { convertClassInstanceToMap });
}).toThrowError(`${errorPrefix} Pass string value instead.`);
}).toThrowError(`${errorPrefix} Use NumberValue from @aws-sdk/lib-dynamodb.`);
BigInt = BigIntConstructor;
});
});
Expand All @@ -81,13 +81,13 @@ describe("convertToAttr", () => {

expect(() => {
convertToAttr(num, { convertClassInstanceToMap });
}).toThrowError(`${errorPrefix} Use BigInt.`);
}).toThrowError(`${errorPrefix} Use NumberValue from @aws-sdk/lib-dynamodb.`);

const BigIntConstructor = BigInt;
(BigInt as any) = undefined;
expect(() => {
convertToAttr(num, { convertClassInstanceToMap });
}).toThrowError(`${errorPrefix} Pass string value instead.`);
}).toThrowError(`${errorPrefix} Use NumberValue from @aws-sdk/lib-dynamodb.`);
BigInt = BigIntConstructor;
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/util-dynamodb/src/convertToAttr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const convertToStringAttr = (data: string | String): { S: string } => ({ S: data
const convertToBigIntAttr = (data: bigint): { N: string } => ({ N: data.toString() });

const validateBigIntAndThrow = (errorPrefix: string) => {
throw new Error(`${errorPrefix} ${typeof BigInt === "function" ? "Use BigInt." : "Pass string value instead."} `);
throw new Error(`${errorPrefix} Use NumberValue from @aws-sdk/lib-dynamodb.`);
};

const convertToNumberAttr = (num: number | Number): { N: string } => {
Expand Down

0 comments on commit 1902196

Please sign in to comment.