Skip to content

Commit c4818d9

Browse files
make error message for overflows more accurate
1 parent a001590 commit c4818d9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/long.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,9 @@ export class Long extends BSONValue {
347347
// doing this check outside of recursive function so cleanedStr value is consistent
348348
const result = Long.fromStringHelper(cleanedStr, unsigned, radix, true);
349349
if (result.toString(radix).toLowerCase() !== cleanedStr.toLowerCase()) {
350-
throw new BSONError(`Input: ${str} is not representable as a Long`);
350+
throw new BSONError(
351+
`Input: ${str} is not representable as ${result.unsigned ? 'an unsigned' : 'a signed'} 64-bit Long with radix: ${radix}`
352+
);
351353
}
352354
return result;
353355
}

0 commit comments

Comments
 (0)