Skip to content

Commit eeca42a

Browse files
authored
Merge pull request #25 from hirosystems/fix/remove-input-from-error-messages
fix: remove input from error messages
2 parents 9e105a0 + 8e09026 commit eeca42a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
dist
3+
.idea

src/helpers/values.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function parseBoolean(val: string | undefined | null): boolean {
4343
case 'no':
4444
return false;
4545
default:
46-
throw new Error(`Cannot parse boolean from "${val}"`);
46+
throw new Error(`Cannot parse boolean`);
4747
}
4848
}
4949

@@ -64,10 +64,10 @@ export function hexToBuffer(hex: string): Buffer {
6464
return Buffer.alloc(0);
6565
}
6666
if (!hex.startsWith('0x')) {
67-
throw new Error(`Hex string is missing the "0x" prefix: "${hex}"`);
67+
throw new Error(`Hex string is missing the "0x" prefix`);
6868
}
6969
if (hex.length % 2 !== 0) {
70-
throw new Error(`Hex string is an odd number of digits: ${hex}`);
70+
throw new Error(`Hex string is an odd number of digits`);
7171
}
7272
return Buffer.from(hex.substring(2), 'hex');
7373
}
@@ -82,10 +82,10 @@ export function coerceToBuffer(hex: string | Buffer | ArrayBufferView): Buffer {
8282
hex = hex.substring(2);
8383
}
8484
if (hex.length % 2 !== 0) {
85-
throw new Error(`Hex string is an odd number of characters: ${hex}`);
85+
throw new Error(`Hex string is an odd number of characters`);
8686
}
8787
if (!/^[0-9a-fA-F]*$/.test(hex)) {
88-
throw new Error(`Hex string contains non-hexadecimal characters: ${hex}`);
88+
throw new Error(`Hex string contains non-hexadecimal characters`);
8989
}
9090
return Buffer.from(hex, 'hex');
9191
} else if (Buffer.isBuffer(hex)) {

src/postgres/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ export const PG_TYPE_MAPPINGS = {
1111
if (/^(0x|0X)[a-fA-F0-9]*$/.test(x)) {
1212
// hex string with "0x" prefix
1313
if (x.length % 2 !== 0) {
14-
throw new Error(`Hex string is an odd number of digits: "${x}"`);
14+
throw new Error(`Hex string is an odd number of digits`);
1515
}
1616
return '\\x' + x.slice(2);
1717
} else if (x.length === 0) {
1818
return '\\x';
1919
} else if (/^\\x[a-fA-F0-9]*$/.test(x)) {
2020
// hex string with "\x" prefix (already encoded for postgres)
2121
if (x.length % 2 !== 0) {
22-
throw new Error(`Hex string is an odd number of digits: "${x}"`);
22+
throw new Error(`Hex string is an odd number of digits`);
2323
}
2424
return x;
2525
} else {
26-
throw new Error(`String value for bytea column does not have 0x prefix: "${x}"`);
26+
throw new Error(`String value for bytea column does not have 0x prefix`);
2727
}
2828
} else if (Buffer.isBuffer(x)) {
2929
return '\\x' + x.toString('hex');

0 commit comments

Comments
 (0)