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

Commit 0a96299

Browse files
committed
Include the unrecognized string in the error message
1 parent 467d5ed commit 0a96299

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,10 +703,9 @@ describe('toBuffer', function() {
703703
})
704704

705705
it('should fail with non 0x-prefixed hex strings', function() {
706-
assert.throws(() => ethUtils.toBuffer('11'))
706+
assert.throws(() => ethUtils.toBuffer('11'), '11')
707707
assert.throws(() => ethUtils.toBuffer(''))
708-
709-
assert.throws(() => ethUtils.toBuffer('0xR'))
708+
assert.throws(() => ethUtils.toBuffer('0xR'), '0xR')
710709
})
711710
})
712711

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy