Syntax - Tasty Web Development Treats

909: Handling and Throwing Errors

5 snips
Jun 9, 2025
Dive into the world of error management in JavaScript and TypeScript! Discover how to effectively throw, catch, and log errors without crashing your app. Learn about error structures, stack traces, and the utility of tools like Sentry. The hosts explore client-side versus server-side strategies, including transforming server errors for client clarity. Gain insights into promise errors, error boundaries, and user experience in error notifications. Perfect for anyone looking to improve their debugging skills!
Ask episode
AI Snips
Chapters
Transcript
Episode notes
INSIGHT

Understanding Error Basics

  • JavaScript errors are "thrown" and must be "caught" to handle them properly.
  • Errors contain a name, message, and stack trace which helps debug the source and flow of the error.
ADVICE

Throw Early Catch Later

  • Throw errors in lower-level logic when you don't want to handle them immediately.
  • Catch errors higher up to decide how to display or log them appropriately.
ADVICE

Handling Promise Errors

  • Use try-catch blocks around promise code to handle errors cleanly.
  • Alternatively, use utilities like awaited-to to manage errors and data at the same scope level.
Get the Snipd Podcast app to discover more snips from this episode
Get the app