diff --git a/src/bytes.ts b/src/bytes.ts index 9149d0e1..ab3c2831 100644 --- a/src/bytes.ts +++ b/src/bytes.ts @@ -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') { diff --git a/test/index.js b/test/index.js index b9e5bd94..9a558f19 100644 --- a/test/index.js +++ b/test/index.js @@ -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') }) })