Showing posts from December, 2017

Error handling in Upspin

The Upspin project uses a custom package,, to represent error conditions that arise inside the system. These errors satisfy the standard Go error interface, but are implemented using a custom type,, that has properties that have proven valuable to the project.

Here we will demonstrate how the package works and how it is used. The story holds lessons for the larger discussion of error handling in Go.


A few months into the project, it became clear we needed a consistent approach to error construction, presentation, and handling throughout the code. We decided to implement a custom errors package, and rolled one out in an afternoon. The details have changed a bit but the basic ideas behind the package have endured. These were:

To make it easy to build informative error messages.To make errors easy to understand for users.To make errors helpful as diagnostics for programmers.
As we developed experience with the package, some other motivations…