Choose Category
package main import ( "fmt" errors "github.com/pkg/errors" ) func main() { anotherMethod() println("After handling") } func anotherMethod() { defer func() { if err := recover(); err != nil { fmt.Printf("work failed: %+v \n", err) } }() method() } func method() (int, error) { panic("fatal error") return 1, errors.New("my error") }