Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Improve error handling for invalid credentials and environment variable #226

Open
adriacidre opened this issue Mar 24, 2023 · 0 comments
Open

Comments

@adriacidre
Copy link
Contributor

I encountered an issue when initializing the self-sdk library with invalid credentials. When this happens, a 401 error is thrown, and the error message is not very informative for the end-user.

The error message looks like this:

[2023-03-24T09:00:54.000Z] WARN AxiosError: Request failed with status code 401
    at settle (/Users/adriancidrejugo/tmp/self-ts-sdk/_examples/authentication/node_modules/axios/dist/node/axios.cjs:1900:12)
    at IncomingMessage.handleStreamEnd (/Users/adriancidrejugo/tmp/self-ts-sdk/_examples/authentication/node_modules/axios/dist/node/axios.cjs:2952:11)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 'ERR_BAD_REQUEST',
  config: [Object],
  request: [ClientRequest],
  response: [Object]
}
(node:45046) UnhandledPromiseRejectionWarning: Error: internal error
    at new IdentityService (/Users/adriancidrejugo/tmp/self-ts-sdk/_examples/authentication/node_modules/self-sdk/dist/self-sdk.umd.js:967:32)
    at Function.<anonymous> (/Users/adriancidrejugo/tmp/self-ts-sdk/_examples/authentication/node_modules/self-sdk/dist/self-sdk.umd.js:8139:51)
    at step (/Users/adriancidrejugo/tmp/self-ts-sdk/_examples/authentication/node_modules/self-sdk/dist/self-sdk.umd.js:107:27)
    at Object.next (/Users/adriancidrejugo/tmp/self-ts-sdk/_examples/authentication/node_modules/self-sdk/dist/self-sdk.umd.js:88:57)
    at fulfilled (/Users/adriancidrejugo/tmp/self-ts-sdk/_examples/authentication/node_modules/self-sdk/dist/self-sdk.umd.js:78:62)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:45046) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:45046) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To improve the user experience and provide better guidance for troubleshooting, I suggest improving the error handling in the library when initializing with invalid credentials or when the SELF_ENV environment variable is set incorrectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant