Skip to content

Commit db6bdfb

Browse files
authored
fix: more specific error messages (#268)
Make errors more informative.
1 parent 5e4eef3 commit db6bdfb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: src/convert.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ function ip2bytes (ipString: string) {
110110

111111
function bytes2ip (ipBuff: Uint8Array) {
112112
const ipString = ip.toString(ipBuff, 0, ipBuff.length)
113-
if (ipString == null || !ip.isIP(ipString)) {
114-
throw new Error('invalid ip address')
113+
if (ipString == null) {
114+
throw new Error('ipBuff is required')
115+
}
116+
if (!ip.isIP(ipString)) {
117+
throw new Error(`invalid ip address "${ipString}"`)
115118
}
116119
return ipString
117120
}

0 commit comments

Comments
 (0)