modulepackage
0.0.0-20180330101621-d1b62e904ab2
Repository: https://github.com/oxequa/grace.git
Documentation: pkg.go.dev
# 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.
package main
import (
"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.
Contributing
Please read our guideline here.
License
Grace is licensed under the GNU GENERAL PUBLIC LICENSE V3.
# Functions
Def if error is nil return a new error with the interface as error value.
Empty check if error message is an empty string.
Equal check if two errors are equal.
New return an error created on the base of a given interface.
Prefix an error with one or a list of custom value.
Recover set an error pointer to recover error with stack trace.
Set if error is not nil return a new error with the interface as error value.