Documentation
¶
Overview ¶
Package guard is the one place a panic stops being fatal. codeaf is event-sourced: the graph loses nothing when a goroutine dies, so a fault should be absorbed, recorded, and degraded around — never allowed to take the terminal surface down while the user is working.
It is deliberately three functions and one error type. Anything larger would be a framework, and a framework is not what a deferred recover needs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Go ¶
func Go(scope string, fn func())
Go spawns fn under Recover. Every fire-and-forget goroutine in codeaf starts here, so "no goroutine can kill the surface" is one grep, not a habit.
func IsFault ¶
IsFault reports whether err came from a recovered panic, which is how a caller tells "the work failed" from "the work faulted".
func Note ¶
Note records a recovered panic and returns the error that stands in for it. Call it from a deferred recover when the fault must become a result rather than end the goroutine. The stack is written once, here.
func Recover ¶
func Recover(scope string)
Recover absorbs a panic in the deferring goroutine and lets it end quietly: `defer guard.Recover("narrator")`. Use it where there is no result to carry the fault — a fire-and-forget spawn whose only obligation is not to crash.
func SetOnFault ¶
SetOnFault installs the hook, or removes it with nil.