Documentation
¶
Overview ¶
Package panicsafe turns a panic into a reported, recoverable error instead of a silent process death. The proxy serves many concurrent LLM calls; a panic in any of them (a nil deref, a bad vendor response) would otherwise take the service down with nothing in Sentry to explain it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Guard ¶
func Guard(where string)
Guard recovers a panic in the current goroutine and reports it. Defer it as the first statement inside a spawned goroutine:
go func() {
defer wg.Done()
defer panicsafe.Guard("worker: process job")
...
}()
Deferred functions run last-in-first-out, so Guard (deferred after wg.Done) runs first on a panic — it recovers, then wg.Done still runs, so a panic never leaves a WaitGroup un-Done.
func Report ¶
Report captures a recovered panic value as a first-class Sentry exception (with the panic stacktrace, so issues group by origin) and logs a console breadcrumb. It is a no-op when r is nil. Safe when Sentry is disabled: the default hub has no client and the capture/flush become no-ops.
The console line is logged at warn, not error, on purpose: the service's zerolog->Sentry writer captures error-level logs, so logging the panic at error would double-report it. The authoritative Sentry event is the hub.Recover exception below.
Types ¶
This section is empty.