https://github.com/thepkg/recover
Package recover contains basic functions which helps to work with recover in bit pleasant way.
https://github.com/thepkg/recover
go golang recover recovery
Last synced: 25 days ago
JSON representation
Package recover contains basic functions which helps to work with recover in bit pleasant way.
- Host: GitHub
- URL: https://github.com/thepkg/recover
- Owner: thepkg
- License: mit
- Created: 2018-10-11T20:11:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-18T17:46:53.000Z (over 6 years ago)
- Last Synced: 2025-12-25T21:57:33.099Z (6 months ago)
- Topics: go, golang, recover, recovery
- Language: Go
- Homepage: https://godoc.org/github.com/thepkg/recover
- 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
Recover
-
[](https://circleci.com/gh/thepkg/recover)
[](https://goreportcard.com/report/github.com/thepkg/recover)
[](https://godoc.org/github.com/thepkg/recover)
Package `recover` contains basic functions
which helps to work with `recover` in bit pleasant way.
## Installation
`go get -u github.com/thepkg/recover`
## Usage
````go
import "github.com/thepkg/recover"
// Performs recover in case of panic with error ErrorUsernameBlank
// otherwise panic won't be recovered and will be propagated.
defer recover.One(ErrorUsernameBlank, func(err interface{}) {
fmt.Printf("got error: %s", err)
})
// Performs recover in case of panic with error ErrorUsernameBlank or ErrorUsernameAlreadyTaken
// otherwise panic won't be recovered and will be propagated.
defer recover.Any([]error{ErrorUsernameBlank, ErrorUsernameAlreadyTaken}, func(err interface{}) {
fmt.Printf("got error: %s", err)
})
// Performs recover for all panics.
defer recover.All(func(err interface{}) {
fmt.Printf("got error: %s", err)
})
````