TIL that it's possible in JavaScript to directly chain a catch
handler to an
await
expression:
await fetchProfile().catch((e) => handleFetchProfileError(e));
Note that this can be done outside (and without requiring) a try/catch
block.
This can be specially useful when you'd want the execution to continue and/or
treat the await
expression individually (i.e., not only one single catch
for
a block of code).
Many thanks to all contributors in this Stack Overflow thread.