JAVASCRIPT CLIMBSChapter 6 · JS Async and Errors
Catching errors with try-catch
Use try...catch to intercept errors. You can throw custom errors using the throw statement.
Worked example
How it reads
- throw new Error(...) creates and fires an error object
- catch (error) receives the thrown error

Cloud tip: You can also use a finally block to execute code regardless of whether an error was thrown.


