lib/httpserver: add Unwrap method to ErrorWithStatusCode, so As and Is functions in standard errors package may properly unwrap the error inside ErrorWithStatusCode

This commit is contained in:
Aliaksandr Valialkin 2020-07-01 00:53:43 +03:00
parent 84a37098ed
commit b277ba8121

View file

@ -506,6 +506,13 @@ type ErrorWithStatusCode struct {
StatusCode int
}
// Unwrap returns e.Err.
//
// This is used by standard errors package. See https://golang.org/pkg/errors
func (e *ErrorWithStatusCode) Unwrap() error {
return e.Err
}
// Error implements error interface.
func (e *ErrorWithStatusCode) Error() string {
return e.Err.Error()