Skip to content

Glossary: Algorithms Beyond the Basics in JavaScript

Error handling (throw, try/catch)

Also written: throw, try/catch, try, catch, new Error

`throw new Error(...)` stops a function with an error, and a `try`/`catch` block catches it so the program can print a clear message instead of crashing. It can be used, for example, to report a cycle in a set of task rules.

Where the book teaches it

Related terms

CycleKahn's algorithm