https://github.com/snicol/yael
Yet Another Error Library
https://github.com/snicol/yael
Last synced: 3 months ago
JSON representation
Yet Another Error Library
- Host: GitHub
- URL: https://github.com/snicol/yael
- Owner: snicol
- License: mit
- Created: 2020-05-04T19:08:16.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-06T19:03:29.000Z (about 5 years ago)
- Last Synced: 2025-01-30T01:26:54.513Z (5 months ago)
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yael

Yet Another Error Library
> Yael (Hebrew: יעל, pronounced [jaˈʔel]; also spelled Jael) is a female given
name, from the Hebrew meaning "Nubian Ibex".Similar code is used across a lot of my side projects so I decided to
standardise it.## Usage
```go
// Errors with metadata
err := yael.New("permission_denied").WithMeta("user", 123)// Wrapping errors
notAdminErr := yael.New("not_admin")
err = err.WithReason(notAdminErr)// Satisfies Go's error interface
fmt.Println(err) // permission_denied// Also Go 1.13+ error wrapping
errors.Is(err, notAdminErr) // true// JSON representable:
{
"code": "permission_denied",
"meta": {
"user": 123
},
"reason": {
"code": "not_admin"
}
}
```