23 lines
355 B
Go
23 lines
355 B
Go
|
package wat
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"runtime"
|
||
|
)
|
||
|
|
||
|
func handleError(err error) string {
|
||
|
if err != nil {
|
||
|
pc, _, _, ok := runtime.Caller(1)
|
||
|
details := runtime.FuncForPC(pc)
|
||
|
var cFun string
|
||
|
if ok && details != nil {
|
||
|
cFun = details.Name()
|
||
|
} else {
|
||
|
cFun = "???"
|
||
|
}
|
||
|
fmt.Printf("caught error in %s: %v\n", cFun, err)
|
||
|
return "u wat"
|
||
|
}
|
||
|
return ""
|
||
|
}
|