From b519ecf4f35008301c4960438fa23421d685a62d Mon Sep 17 00:00:00 2001 From: KX-Apple <57068530+AnAppleforlife@users.noreply.github.com> Date: Tue, 4 May 2021 20:31:27 +0200 Subject: [PATCH] Error handling --- funi.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/funi.js b/funi.js index 872134e..6dc0c7e 100644 --- a/funi.js +++ b/funi.js @@ -783,11 +783,12 @@ async function downloadPart(chunk, index) { responseType: 'buffer' }).catch(error => console.log(`[ERROR] ${error.name}: ${error.code||error.message}`))); - if (!res.body) { return; } - - let dec = key.update(res.body); - dec = Buffer.concat([dec, key.final()]); - return { content: dec, index: index}; + if (!res.body) { return new Error("Invalid State"); } + try { + let dec = key.update(res.body); + dec = Buffer.concat([dec, key.final()]); + return { content: dec, index: index}; + } catch (e) { return e } } let keys = {};