https://github.com/echoutopia/zerror
zerror makes your busines projects error management simple and powerful
https://github.com/echoutopia/zerror
err-code error error-log golang organize-errors predefined-errors
Last synced: 9 days ago
JSON representation
zerror makes your busines projects error management simple and powerful
- Host: GitHub
- URL: https://github.com/echoutopia/zerror
- Owner: EchoUtopia
- Created: 2019-10-31T09:13:52.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-25T07:11:38.000Z (over 4 years ago)
- Last Synced: 2025-02-06T05:54:33.953Z (12 months ago)
- Topics: err-code, error, error-log, golang, organize-errors, predefined-errors
- Language: Go
- Homepage:
- Size: 211 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# ZError
## Notice
v1 is deprecated, please use v2
import path : `github.com/EchoUtopia/zerror/v2`
example import path: `github.com/EchoUtopia/zerror/examples/v2`
[中文文档](./Readme_zh.md)
## Terminology
- Error Definition(zerror.Def): error definition to generate or wrap error
## Features
- Predefine errors
- Make error code predefined and standard
- Specified error definition Status Code for Http, Grpc and so on
- Classify errors with groups
- Some built-in error definitions, like `zerror.NotFound`, `zerror.Forbidden` and so on
- List all error codes and corresponding infos(descriptions, status code, etc)
- Extension for every error definition to do many cool things you want.
## Examples:
```go
func DoSomething()error {
***
// return zerror.Internal.Wrap(errors.New(`***`))
return zerror.BadRequest.New()
}
```
## full examples
see in examples directory
## Why is zerror made
I want errors to be clearly organized and reusable and classified in groups
I want hide errors from client and return code instead
I want to respond predefined code and log error in one line code
I want to respond with different Status Code for Grpc/Http for error generated/wrapped by zerror
so Zerror is here