Skip to content

proposal: runtime: add a function to install a global go-routine panic handler  #55038

@markusheukelom

Description

@markusheukelom
package runtime

// Recover installs a handler function that is called whenever a panicking sequence
// in any Go routine is not stopped by a call to recover in a locally deferred function call. 
//
// If no handler function is installed the program aborts.
//
// By default, no handler function is installed.
// 
// The handler function runs as if a defer-recover preamble was added to the function on 
// which the `go` operatorr is invoked:
//  
//     defer func() { if r := recover(); r != nil { handler(r) } }
//
// This means that, for example, the stack of the panicking go-routine can be retrieved use `debug.Stack`, etc.
func Recover(handler func(r any)) {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeProposalWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions