An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

github.com/pingcap/errcode

Package errcode facilitates standardized API error codes. The goal is that clients can reliably understand errors by checking against immutable error codes This godoc documents usage. For broader context, see https://github.com/pingcap/errcode/tree/master/README.md Error codes are represented as strings by CodeStr (see CodeStr documentation). This package is designed to have few opinions and be a starting point for how you want to do errors in your project. The main requirement is to satisfy the ErrorCode interface by attaching a Code to an Error. See the documentation of ErrorCode. Additional optional interfaces HasClientData, HasOperation, Causer, and StackTracer are provided for extensibility in creating structured error data representations. Hierarchies are supported: a Code can point to a parent. This is used in the HTTPCode implementation to inherit HTTP codes found with MetaDataFromAncestors. The hierarchy is present in the Code's string representation with a dot separation. A few generic top-level error codes are provided (see the variables section of the doc). You are encouraged to create your own error codes customized to your application rather than solely using generic errors. See NewJSONFormat for an opinion on how to send back meta data about errors with the error data to a client. JSONFormat includes a body of response data (the "data field") that is by default the data from the Error serialized to JSON. Stack traces are automatically added by NewInternalErr and show up as the Stack field in JSONFormat. Errors can be grouped with Combine() and ungrouped via Errors() which show up as the Others field in JSONFormat. To extract any ErrorCodes from an error, use CodeChain(). This extracts error codes without information loss (using ChainContext).

Ecosystem
proxy.golang.org
Latest Release
v0.3.0
almost 7 years ago
Versions
1
Dependent Packages
18
Dependent Repos
388
Links
Registry proxy.golang.org
Source Repository
Docs Documentation
JSON API View JSON
CodeMeta codemeta.json
Package Details
PURL pkg:golang/github.com/pingcap/errcode
spec
License Apache-2.0
Namespace github.com/pingcap
First Release almost 7 years ago
Last Synced 25 days ago
Repository
Stars 14 on GitHub
Forks 4 on GitHub
Docker Dependents 24
Docker Downloads 4,053,522
Rankings on proxy.golang.org
Overall Top 4.0%
Dependent packages Top 1.2%
Dependent repos Top 0.3%
Forks Top 8.9%
Docker downloads Top 0.5%