Skip to content

proposal: runtime: support to call finalizing function when throw() is called #56702

Closed
@mbrancato

Description

@mbrancato

When the runtime calls throw() for unrecoverable errors, it would be nice if there was a way to register a finalizer function to be called that would allow capturing the error in something other than stdout/stderr. This would differ from recover() in that it would still raise the error.

Background:

I'm using a web service in Go, it processes requests using goroutines. In one step, a key may be added to a map (e.g. map[string]string). In about 1 in a billion requests, under high request volume, the following fatal error is raised:

fatal error: concurrent map writes

We use an error logging library that "catches" panic() and stores the errors for tracking. I wanted to see this error be captured by that logging library. Since this error uses throw(), it cannot be handled by recover().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions