In javascript, is it possible to perform object destructing while still handling an exception? For example this is what I would ideally like to be able to do the syntax isn't valid
let body;
let err;
try {
{ body } = await networkRequest(...); // invalid syntax
} catch (e) {
err = e;
}
From what I can tell the options are to either:
Don't use object destructuring
Don't handle the exception
Scope the destructed to the try block
Is it possible to achieve object destructuring and handle an exception?