1 bookmark for 2024-03-06

Reposted 1180.

Wrapping Errors in Go - How to Handle Nested Errors

blog.boot.dev/golang/wrapping-errors-in-go-how-to-handle-nested-errors

By wrapping errors and building well-formatted error messages, we can keep better track of where errors are happening. I often just add the name of the function being called to my error messages, but we can make the message say whatever we want. For example, I’ll often include parameter information in the error so I know which inputs caused the error.