Better Stack on YouTube · Open on YouTube
Professional practice · Competent · Lesson 39 of 98 · 12 min video, then about 5 hours of practice
Error handling and logging
After this you can handle errors at the right layer, show users a useful message, and log enough structured context to debug a problem you cannot reproduce.
Why it matters
In production you cannot attach a debugger. What you have is logs. Log errors with context (which user, which request, what input) in a structured format, and never swallow an exception silently. Decide where each error is handled: validation errors become 400s with a message, unexpected errors become 500s with a generic message to the user and full detail in the log. Trap: logging secrets or personal data. Logs are often less protected than databases.
How to use this resource
Twelve concrete logging practices, each one worth adopting.