This is a drop-in replacement for the standard Go package with the same name, providing all the standard functionality as well as additional features.
v1.0.1 Stable: Guaranteed no breaking changes to the API in future v1.x releases. Probably safe to use in production, though provided on "AS IS" basis.
This package is being actively maintained. If you encounter any problems or have any suggestions for improvement, please open an issue. Pull requests are welcome.
When you need to retain more information about an error message than a single string allows, just substitute this package for the one in the standard library.
The New function still accepts a single string as argument, so no code will be broken. Where you need to include additional information, you can provide it to New in a Desc structure instead of the string, or you can add it to the error message using one of its setter methods.
The additional information can be used for smarter error handling and logging:
Leveldifferentiates between warnings, regular errors, panics, and fatal errors;Codeallows custom classification and prioritizing, by using ranges or bit-level masks;Infooffers a store for arbitrary data and messages, besides the main errorText; the special string"debug.stack", if present as an element in the Info slice, is automatically replaced by a stack trace at the point the error message has been created.
go get github.com/agext/errors
Package errors is released under the Apache 2.0 license. See the LICENSE file for details.