Skip to content

Commit 1d17159

Browse files
author
Seong-Uk Cho
committed
added try catch to get tags api
1 parent c4adf76 commit 1d17159

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ const child_process = require('child_process'),
2525
delete argv.target;
2626

2727
async function getTags(page){
28-
var res = await fetch("https://api.github.com/repos/SonarSource/sonar-scanner-cli/tags"
29-
+"?page="+page, fetchOptions)
30-
var data = await res.json();
31-
28+
try{
29+
var res = await fetch("https://api.github.com/repos/SonarSource/sonar-scanner-cli/tags"
30+
+"?page="+page, fetchOptions)
31+
var data = await res.json();
32+
} catch (err) {
33+
console.error(err);
34+
throw new Error("Couldn't get tags from Github API.");
35+
}
3236
if (data.length == 0){
3337
throw new Error("Couldn't find target sonar-scanner-cli version: "
3438
+ SONAR_VERSION);

0 commit comments

Comments
 (0)