Closed as not planned
Description
Problem
Most of the time in Go if an error occurs it can be returned. There are certain cases when this is not possible, usually go
functions.
go func(){
if err := foo(); err != nil {
// cannot 'return err' because the function has already returned
}
}
Packages shouldn't choose how to handle errors so they end up either squashing the error or making configurable error logging like ErrorLog
in httputil.ReverseProxy or http.Server.
Proposal
I propose adding a function errors.Handle(error)
that can be called in cases where it is impossible to return an error.
There should be a second function errors.SetHandler(func(error))
that can be called, usually in main
, that lets an application choose how to handle an error. (i.e. log, increment a metrics, ...)