I have this situation
try {
const foo = await Foo();
} catch (error) {
console.error(error);
throw error;
}
I have to do a fair amount of stuff with the foo
variable.
Is there a way I can use the foo
variable without ending up nested several layers deeper because of try/catch blocks like this? This standard pattern won't work because it's const (and I prefer it to be const):
let x;
try {
x = await X():
} catch (error) {
throw error;
}
console.log(x);