https://github.com/reedchan7/errx
errx is a simple and easy to use error handling library.
https://github.com/reedchan7/errx
error error-handling stacktrace
Last synced: about 1 year ago
JSON representation
errx is a simple and easy to use error handling library.
- Host: GitHub
- URL: https://github.com/reedchan7/errx
- Owner: reedchan7
- License: mit
- Created: 2024-10-15T08:53:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-15T08:55:22.000Z (over 1 year ago)
- Last Synced: 2024-10-16T04:58:45.524Z (over 1 year ago)
- Topics: error, error-handling, stacktrace
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# errx
`errx` is a more modern and convenient error handling library, providing more user-friendly stacktrace:
# Install
```shell
go get github.com/reedchan7/errx
```
# Quick Start
```go
err := errx.New("oops: something wrong :(")
err = errx.Wrap(err, "failed to do something")
fmt.Printf("%+v\n", err)
```
# Example
```go
err := errx.NewInternalServerError().New("failed to do something")
err = errx.Wrap(err, "oops: :(")
err = errx.Wrapf(err, "xxxxxxx")
fmt.Printf("%+v\n", err)
```
Result:
```text
500: Internal Server Error: xxxxxxx: oops: :(: failed to do something
Thrown: failed to do something
--- at /home/user/go/pkg/errx/errx_test.go:17 TestCode1()
Thrown: oops: :(
--- at /home/user/go/pkg/errx/errx_test.go:18 TestCode1()
Thrown: xxxxxxx
--- at /home/user/go/pkg/errx/errx_test.go:19 TestCode1()
```