View definition

func EnterFuncWithRecovers

Defined in github.com/mailgun/godebug/lib/debug.go

Description

EnterFuncWithRecovers is a special wrapper for functions that call recover(). recover only works if it is called directly by a deferred function. It does not work if a deferred function calls a function that in turn calls another function that calls recover. But EnterFunc and EnterFuncLit depend on being able to wrap their functions and call them farther down in the stack.

The solution is to create a new goroutine, use EnterFuncLit as normal in the new goroutine, and have the code generator replace calls to recover with channel communications. Then in the original function frame, we call recover when asked to and pass its value into the new goroutine over a channel.

EnterFuncWithRecovers takes care of maintaining goroutine-local-storage in the new goroutine, as well as propagating any panic from that goroutine to the original goroutine.

EnterFuncWithRecovers is referenced in 0 repositories