Another error handling mechanism for Go
Go to file
2020-06-25 17:54:04 +04:30
aerr.go fix 2020-06-25 17:54:04 +04:30
LICENSE add License and reame files 2020-01-15 14:13:15 +03:30
README.md update doc 2020-06-25 12:42:04 +00:00

Aerr (Ar) A tiny and simple but useful go packge. It's contains two methods for a throw-catch like error handling mechanism for Go. Use defer Ignore({handler?}) for catching and Panicerr({error?}) for throwing.

func PrintPanicedWithoutCrash(e interface{}){
    fmt.Println(e)
}
func aFuncThatMayHasErrorsAndPanics(){
    defer Catch(PrintPanicedWithoutCrash)
    thereIsSomeNonNilError := errors.New("somewhat")
    //without need to write an ugly if like this
    ////if thereIsSomeNonNilError != nil {
    ////    panic(thereIsSomeNonNilError)
    ////}
    //just need to pass it to the Panicerr
    Panicerr(thereIsSomeNonNilError)
}