JS ⟩ asynchronous ⟩ await ⟩ error handling
catch await errors by try...catch.
(async () => { // catch await errors by try...catch statement. try { let response = await fetch(url); } catch(err) { console.log(err); } })();
catch async function errors by Promise.prototype.catch().
(async () => { let response = await fetch(url); })().catch(err => { // catch a rejected Promise returned by async func console.log(err) });
JS.info ⟩
async / await
error handling with Promises
Promise ⟩ error handling
Promise.prototype.catch()
unhandledrejection event
Last updated 2 years ago