Getting the Most out of JavaScript Errors
summary
Explains that Error.stack is generated when an Error is instantiated, not when thrown, so rethrowing the same Error preserves the original trace while creating a new Error loses root context; shows how to copy original stack onto a custom Error and how to synthesize a trace by creating an Error when catching non‑Error throws. Notes async gaps (Node 12 and async/await give better async stacks; Chrome devtools show extra frames but Error.stack often doesn’t), warns against throwing primitives, details Script error due to cross-origin and the fix: add crossorigin="anonymous" plus Access-Control-Allow-Origin. Recommends using Sentry for collection.
AI-written summary · about
chapters (12)
- 0:00Introduction to JavaScript errors
- 2:25Error object basics
- 5:35Creating custom errors
- 7:00Stack traces explained
- 9:50Async stack traces limitations
- 12:47Non-standard stack properties
- 14:31Throwing non-error objects
- 17:21Synthetic error traces
- 18:43Reporting errors globally
- 21:58Browser error handlers
- 23:02Cross-origin script errors
- 25:31Key takeaways summary
related talks
27mTraces of Errors: Getting Better JavaScript Stacktraces
28mError handling: doing it right!
40mManeuvering Errors within the Bowels of JavaScript
23mKicking Bugs and Logging Names: Errors in JavaScript Error Reporting
32mExpect the Unexpected: How to Deal with Errors in Large Web Applications
27mManeuvering Errors Within the Bowels of JavaScript
20mUnhandled rejections and other awaited promise tales
25mDebugging async JS
