Hello,
What do you think of errors' contexts like net/context or simple map[string]interface{} stored with the original error?
It would be really handy; example:
var ErrNotFound = error.New("Page not found!")
...
return errors.Wrap(ErrNotFound,pageTitle).WithContext(`http`,404)
this way the imaginary http handler won't need to know about ErrNotFound; it would just grab the value from the context. It could be even better:
var ErrNotFound = errors.Wrap(error.New("Page not found!"),"").WithContext(`http`,404)
...
return errors.Wrap(ErrNotFound,pageTitle)
however, this approach would lose stack data; it would require the stored stack's reset.
The context or map can be initiated on demand (when adding first value), so it wouldn't create some significant overhead if context is not used.
Hello,
What do you think of errors' contexts like
net/contextor simplemap[string]interface{}stored with the original error?It would be really handy; example:
this way the imaginary http handler won't need to know about ErrNotFound; it would just grab the value from the context. It could be even better:
however, this approach would lose stack data; it would require the stored stack's reset.
The context or map can be initiated on demand (when adding first value), so it wouldn't create some significant overhead if context is not used.