Is it possible to "repair" the error with recoverand keep the original stack trace? The best I know how to do this is to panic again, but this creates a new stack.
func do() {
defer func() {
cleanUp()
if x := recover(); x != nil {
handleError()
panic(x)
}
}()
doStuff()
}
My motivation for this is that if my function does not work out normally or handleErrorworks, my program will be blocked. And if I don’t save the original trace, I don’t know where it crashed.
source
share