Lets imagine I have a scenario like this:
async function some_func() {
await some_query.catch(async (e) => {
await some_error_code()
})
console.log('The above function ran without an error')
}
I only wish for the console.log()
to be reached if the asynchronous function ran successfully. At the moment, my solution is:
async function some_func() {
let did_error = false
await some_query.catch(async (e) => {
await some_error_code()
did_error = true
})
if (did_error) return
console.log('The above function ran without an error')
}
But that's not great. Is there any way of handling this without the added bulk? Similar to multiple for loops:
outer: for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
continue outer;
}
console.log('Never called')
}