From 81e3d4305f060cc2ec8559251ff9739f9dec1fdc Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 1 Jul 2020 00:53:43 +0300 Subject: [PATCH] lib/httpserver: add Unwrap method to ErrorWithStatusCode, so `As` and `Is` functions in standard `errors` package may properly unwrap the error inside ErrorWithStatusCode --- lib/httpserver/httpserver.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/httpserver/httpserver.go b/lib/httpserver/httpserver.go index 739b31d911..ca4f77f386 100644 --- a/lib/httpserver/httpserver.go +++ b/lib/httpserver/httpserver.go @@ -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()