From a97c4ddbc78817793be31d05ea1e197fda247168 Mon Sep 17 00:00:00 2001 From: rafapaezbas Date: Fri, 6 Sep 2024 15:24:47 +0200 Subject: [PATCH] throw decoding error --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c37544bb..805e67bf 100644 --- a/index.js +++ b/index.js @@ -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') @@ -862,7 +863,11 @@ module.exports = class Hypercore extends EventEmitter { this.encryption.decrypt(index, block) } - return this._decode(encoding, block) + try { + return this._decode(encoding, block) + } catch { + throw DECODING_ERROR() + } } async clear (start, end = start + 1, opts) {