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

Commit

Permalink
Include the unrecognized string in the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
alcuadrado committed May 14, 2019
1 parent d8aee9c commit f0df622
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bytes.ts
Expand Up @@ -76,7 +76,7 @@ export const toBuffer = function(v: any): Buffer {
v = Buffer.from(ethjsUtil.padToEven(ethjsUtil.stripHexPrefix(v)), 'hex')
} else {
throw new Error(
'Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings.',
`Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ${v}`,
)
}
} else if (typeof v === 'number') {
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Expand Up @@ -507,9 +507,9 @@ describe('toBuffer', function () {
})

it('should fail with non 0x-prefixed hex strings', function() {
assert.throws(() => ethUtils.toBuffer('11'))
assert.throws(() => ethUtils.toBuffer('11'), '11')
assert.throws(() => ethUtils.toBuffer(''))
assert.throws(() => ethUtils.toBuffer('0xR'))
assert.throws(() => ethUtils.toBuffer('0xR'), '0xR')
})
})

Expand Down

0 comments on commit f0df622

Please sign in to comment.