Skip to content

Commit fcf3ca0

Browse files
authored
Replace varint assert with exception (#146)
1 parent 3cb014a commit fcf3ca0

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

src/datatypes/utils.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const assert = require('assert')
2-
31
const { getCount, sendCount, calcCount, PartialReadError } = require('../utils')
42

53
module.exports = {
@@ -77,7 +75,7 @@ function readVarInt (buffer, offset) {
7775
}
7876
}
7977
shift += 7 // we only have 7 bits, MSB being the return-trigger
80-
assert.ok(shift < 64, 'varint is too big') // Make sure our shift don't overflow.
78+
if (shift > 64) throw new PartialReadError(`varint is too big: ${shift}`) // Make sure our shift don't overflow.
8179
}
8280
}
8381

0 commit comments

Comments
 (0)