Skip to content

Instantly share code, notes, and snippets.

@adamweeks
Created March 4, 2020 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamweeks/bb7a8bf0e399dfe1a8e6973b5d49cf8e to your computer and use it in GitHub Desktop.
Save adamweeks/bb7a8bf0e399dfe1a8e6973b5d49cf8e to your computer and use it in GitHub Desktop.
FINALLY
isZero(0)
zero!
FINALLY
isZero()
not zero
FINALLY
error caught
/* eslint-disable require-jsdoc */
async function isZero(param) {
try {
if (param === 0) {
console.log('zero!');
}
else {
throw new Error('not zero');
}
}
catch (error) {
console.log(error.message);
throw error;
}
finally {
console.log('FINALLY');
}
}
console.log('isZero(0)');
isZero(0);
console.log('isZero()');
isZero().catch(() => console.log('error caught'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment