Package recover
contains basic functions
which helps to work with recover
in bit pleasant way.
go get -u github.com/thepkg/recover
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)
})