okta-sdk-nodejs
okta-sdk-nodejs copied to clipboard
DRAFT: Proposed error improvements
There are two common configuration errors that developers run into:
- Invalid API token
- Invalid Org URL (DNS name not found)
In either situation, the underlying HTTP error bubbles up the promise chain.
If the developer has not implemented a catch, they get a generic error about an uncaught promise exception
This improves on that by printing the exceptions for the common cases above, then exiting the process with a non-zero code
You can reproduce the problematic case by running this:
const okta = require('@okta/okta-sdk-nodejs');
const client = new okta.Client({
orgUrl: 'https://fooasdoasdfj.okta-asdofij.com',
token: 'foo',
requestExecutor: new okta.DefaultRequestExecutor()
});
client.listUsers().each(user => {
console.log(user)
}).then(() => {
console.log("Listed users.");
process.exit();
})
I definitely support logging the error. Killing the process may be a bit severe. The Okta integration could be a small part of a much larger application.
I definitely support logging the error. Killing the process may be a bit severe. The Okta integration could be a small part of a much larger application.
That's a good point, we shouldn't exit. I was doing the exit to try to avoid the "UnhandledPromiseRejectionWarning" also being printed, but maybe there's not a good way to do that?