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")
}
You can read the full documentation of Grace here.
Please read our guideline here.
Grace is licensed under the GNU GENERAL PUBLIC LICENSE V3.