https://github.com/alextanhongpin/errors
Golang errors
https://github.com/alextanhongpin/errors
causes errors go golang stacktrace
Last synced: 5 months ago
JSON representation
Golang errors
- Host: GitHub
- URL: https://github.com/alextanhongpin/errors
- Owner: alextanhongpin
- License: bsd-3-clause
- Created: 2023-07-15T09:47:51.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-12T05:06:47.000Z (over 1 year ago)
- Last Synced: 2024-09-12T14:31:10.718Z (over 1 year ago)
- Topics: causes, errors, go, golang, stacktrace
- Language: Go
- Homepage:
- Size: 44.9 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Errors
[](http://godoc.org/github.com/alextanhongpin/errors)
The `errors` package solves some of the pain points when working with errors in golang.
That includes
- optional stacktrace
- annotate stacktrace with cause
- grouping errors with errors `Code`
- custom errors with errors `Kind`
- mapping errors `Code` to HTTP/gRPC status code
- does not conflict with the standard errors package name
Some things that are considered, but is not included when designing this package is
- localization
## Installation
```bash
$ go get github.com/alextanhongpin/errors
```
## Usage
There are three subpackage in the `errors` package, each fulfilling different usecase:
- `causes`: create custom errors
- `codes`: standard error `codes` that can be mapped to `HTTP/gRPC` codes
- `stacktrace`: add stacktrace to errors and annotate cause
Each folder contains usage examples.