-
-
Save Infinitay/bfb1feac73b75a034997d6b0b16b1bab to your computer and use it in GitHub Desktop.
The Programming House Discord Support Post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How come the following snippet's `error` when caught is `undefined`: | |
app.on('ready', () => { | |
Promise.all([......]).then(async () => { | |
... | |
const eventRootFolderId = folderIdRegex.exec(event.link)[1]; | |
... | |
}).catch(error => logger.error(error)); // Undefined | |
}); | |
// But when I try and catch, and then return the caught error, it is then caught and no longer `undefined`. | |
app.on('ready', () => { | |
Promise.all([......]).then(async () => { | |
... | |
try { | |
const eventRootFolderId = folderIdRegex.exec(event.link)[1]; | |
} catch (innerError) { | |
return innerError; // If I change this to something like logger.error(innerError), it also treats innerError to be null, but not when I return it | |
} | |
}).catch(error => logger.error(error)); // No longer undefined | |
}); | |
// I was under the assumption that in the first snippet, or any catch block, it catches any error, therefore I don't need to try...catch within the anonymous async function. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment