Skip to content

Commit

Permalink
lib: handle error while json parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Dec 12, 2023
1 parent aceff20 commit 04ffd2a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 04ffd2a

Please sign in to comment.