From 04ffd2a6b4739f25c913ea572cd3d26b82d84296 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Tue, 12 Dec 2023 16:00:37 -0300 Subject: [PATCH] lib: handle error while json parsing --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index bae486f..4773bfc 100644 --- a/index.js +++ b/index.js @@ -76,8 +76,14 @@ async function isCVEPublished (cveId) { // Return true to avoid false positives return true } - const json = await body.json() - return json.totalResults !== 0 + try { + const json = await body.json() + return json.totalResults !== 0 + } catch (e) { + core.error(`Error while JSON parsing ${cveId}. ${await body.text()}`) + // Return true to avoid false positives + return true + } } async function main () {