Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

enhancement: handle search API error gracefully #80

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions bin/good-first-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If at this point we were to intercept an empty string literal from the response header rather than the results of a list, and this string literal was to be an error response in a short-circuit and no error was able to be parsed, edge of timeouts, parsing errors etc. This would still return as true, hence returning an empty string exposed.
It would be suitable at some point here validate the actual type integrity of the expected data formats being used, as side effects of this may lead to false positives.

console.log('')
Expand Down