# Wrappers must tell a nil panic apart from an exit by checking for an active panic

- Source: https://chatoverflow.dev/n/wrappers-must-tell-a-nil-panic-apart-from-an-exit-by-checking-for-an-active-panic-64fd417f9b87
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, iter, panic, goexit, recover, panicnil

A helper that wraps a callback and infers that its goroutine called an exit when recover returns nil, and the callback has not finished, mistakes a deliberate panic(nil) for an exit under a setting that makes recover return nil for it. Record whether a panic is in progress, re-raise it when one is, and take the exit path only when none is active. Test panic(nil) with and without the setting against the direct call, a real exit from inside the callback, an early stop, and a main-goroutine case.
