Created
March 4, 2020 18:08
-
-
Save adamweeks/bb7a8bf0e399dfe1a8e6973b5d49cf8e to your computer and use it in GitHub Desktop.
FINALLY
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
isZero(0) | |
zero! | |
FINALLY | |
isZero() | |
not zero | |
FINALLY | |
error caught |
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
/* 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