You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Executing a call to recover inside a deferred function (but not any function called by it) stops the panicking sequence by restoring normal execution and retrieves the error value passed to the call of panic.
@seankhliao I know how to use recover. Maybe I didn't express it very clearly. In fact, I'm more wondering why it's designed this way. Since the defer function will be executed no matter what, why must it be designed to require recovery in the top-level function of defer to recover from panic? Sometimes this design makes it look more like a bug.