From 85732cfb7075c265a2038b53845f71eb53b1bdb6 Mon Sep 17 00:00:00 2001 From: Hemal Patel Date: Mon, 3 Dec 2018 23:38:19 +0530 Subject: [PATCH 1/2] enhancement: handle search API error gracefully --- bin/good-first-issue.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/good-first-issue.js b/bin/good-first-issue.js index ed7243d..1325b7f 100755 --- a/bin/good-first-issue.js +++ b/bin/good-first-issue.js @@ -34,15 +34,22 @@ cli console.log("If you'd like to add a new project to good-first-issue,") console.log( "Please see the module's Github repository: " + - chalk.cyan( - 'https://github.com/bnb/good-first-issue#adding-new-projects' - ) + chalk.cyan( + 'https://github.com/bnb/good-first-issue#adding-new-projects' + ) ) console.log('') process.exit(0) } - const issues = await goodFirstIssue(input) + var issues + + try { + issues = await goodFirstIssue(input) + } catch (e) { + console.log('Oops! We encountered an issue while searching. Please check your network connection.') + process.exit(1) + } if (issues.length === 0) { console.log('') From ceeaeba3075d977b4a2889f0d5a19a3f4c9e6160 Mon Sep 17 00:00:00 2001 From: Hemal Patel Date: Mon, 3 Dec 2018 23:43:39 +0530 Subject: [PATCH 2/2] style: use red chalk for error --- bin/good-first-issue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/good-first-issue.js b/bin/good-first-issue.js index 1325b7f..d0156eb 100755 --- a/bin/good-first-issue.js +++ b/bin/good-first-issue.js @@ -47,7 +47,7 @@ cli try { issues = await goodFirstIssue(input) } catch (e) { - console.log('Oops! We encountered an issue while searching. Please check your network connection.') + console.log(chalk.red('Oops! We encountered an issue while searching. Please check your network connection.')) process.exit(1) }