Description
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()
.