JSJavaScript · Lesson 13 of 14
Error Handling & Debugging
JavaScript has one Error type but many error names, a try/catch that silently swallows everything, and async errors that require special handling. The good news: once you understand the three failure modes, it gets simple.
⚠ Warning
Never use empty catch blocks: catch (e) {}. This silently swallows errors and makes debugging a nightmare. At minimum, log the error. If you truly want to ignore an error, write a comment explaining why: // ignore AbortError from cancelled fetch.
Never use empty catch blocks: catch (e) {}. This silently swallows errors and makes debugging a nightmare. At minimum, log the error. If you truly want to ignore an error, write a comment explaining why: // ignore AbortError from cancelled fetch.