Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oxequa/grace
Handle Go recover, panic, and errors in a graceful way. Multiple errors support, basic filters and custom handlers.
https://github.com/oxequa/grace
error-handling go go-library go-tools golang golang-package golang-wrapper
Last synced: about 1 month ago
JSON representation
Handle Go recover, panic, and errors in a graceful way. Multiple errors support, basic filters and custom handlers.
- Host: GitHub
- URL: https://github.com/oxequa/grace
- Owner: oxequa
- License: gpl-3.0
- Created: 2018-03-05T00:12:16.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-30T10:16:21.000Z (over 6 years ago)
- Last Synced: 2024-08-04T06:01:52.910Z (5 months ago)
- Topics: error-handling, go, go-library, go-tools, golang, golang-package, golang-wrapper
- Language: Go
- Homepage: https://grace.oxequa.com
- Size: 30.3 KB
- Stars: 237
- Watchers: 8
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Handle recover, panic and errors in a graceful way
## Quickstart
```
go get github.com/oxequa/grace
```The following is a simple example that handles a panic and returns the error without the program crash.
```go
package mainimport (
"fmt"
"github.com/oxequa/grace"
)func example() (e error){
defer grace.Recover(&e) // save recover error and stack trace to e
numbers := []int{1, 2}
fmt.Println(numbers[3]) // panic out of index
return
}func main() {
err := example() // no panic occur
fmt.Println(err)
fmt.Println("End")
}
```## Documentation
You can read the full documentation of Grace [here](https://grace.oxequa.com).
## Contributing
Please read our guideline [here](CONTRIBUTING.md).
## License
Grace is licensed under the [GNU GENERAL PUBLIC LICENSE V3](LICENSE).