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 fe77d661b3
commit 81e3d4305f

View File

@ -455,6 +455,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()