Skip to content
This repository was archived by the owner on Jun 17, 2021. It is now read-only.

Commit cb86ba9

Browse files
committed
Include the unrecognized string in the error message
1 parent d9b3b0e commit cb86ba9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/bytes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const toBuffer = function(v: any): Buffer {
7676
v = Buffer.from(ethjsUtil.padToEven(ethjsUtil.stripHexPrefix(v)), 'hex')
7777
} else {
7878
throw new Error(
79-
'Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings.',
79+
`Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ${v}`,
8080
)
8181
}
8282
} else if (typeof v === 'number') {

test/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ describe('toBuffer', function () {
507507
})
508508

509509
it('should fail with non 0x-prefixed hex strings', function() {
510-
assert.throws(() => ethUtils.toBuffer('11'))
510+
assert.throws(() => ethUtils.toBuffer('11'), '11')
511511
assert.throws(() => ethUtils.toBuffer(''))
512-
assert.throws(() => ethUtils.toBuffer('0xR'))
512+
assert.throws(() => ethUtils.toBuffer('0xR'), '0xR')
513513
})
514514
})
515515

0 commit comments

Comments
 (0)