Skip to content

Commit

Permalink
throw decoding error
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapaezbas committed Sep 6, 2024
1 parent 88a1a2f commit 8f9c32b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const {
BAD_ARGUMENT,
SESSION_CLOSED,
SESSION_NOT_WRITABLE,
SNAPSHOT_NOT_AVAILABLE
SNAPSHOT_NOT_AVAILABLE,
DECODING_ERROR
} = require('hypercore-errors')

const promises = Symbol.for('hypercore.promises')
Expand Down Expand Up @@ -1108,7 +1109,11 @@ module.exports = class Hypercore extends EventEmitter {

_decode (enc, block) {
if (this.padding) block = block.subarray(this.padding)
if (enc) return c.decode(enc, block)
try {
if (enc) return c.decode(enc, block)
} catch {
throw DECODING_ERROR()
}
return block
}
}
Expand Down

0 comments on commit 8f9c32b

Please sign in to comment.