Skip to content

Gracefully handle the case where a non-existant project is provided on the CLI #361

Description

@godber

When I supply a github user and project that doesn't exist I get a stack trace:

./bin/fetch-github-release -d -o json trycua luma
HTTPError: Response code 404 (Not Found)
    at Request.<anonymous> (file:///Users/godber/Workspace/terascope/opensource/fetch-github-release/node_modules/got/dist/source/as-promise/index.js:86:42)
    at Object.onceWrapper (node:events:634:26)
    at Request.emit (node:events:531:35)
    at Request._onResponseBase (file:///Users/godber/Workspace/terascope/opensource/fetch-github-release/node_modules/got/dist/source/core/index.js:726:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Request._onResponse (file:///Users/godber/Workspace/terascope/opensource/fetch-github-release/node_modules/got/dist/source/core/index.js:768:13) {
  input: undefined,
  code: 'ERR_NON_2XX_3XX_RESPONSE',

It should do the following things in these cases:

  • default txt output - should print a text error message saying the project FOO doesn't exist
  • -q - nothing printed
  • --json should return:
{
  "error": "Project FOO doesn't exist."  /// same message as above
}

In all cases the return code (echo $?) is set to non-zero (e.g. 1, make sure it's unique and documented in the code that the return code indicates the package doesn't exist.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions