internal: use errors.As in IsNotFound

Allows it to work properly with wrapped errors.
This commit is contained in:
Simon Ser 2022-05-31 16:58:45 +02:00
parent 9bc7a8f15b
commit d0fc22a428

View File

@ -2,6 +2,7 @@
package internal
import (
"errors"
"fmt"
"net/http"
)
@ -84,7 +85,11 @@ func HTTPErrorFromError(err error) *HTTPError {
}
func IsNotFound(err error) bool {
return HTTPErrorFromError(err).Code == http.StatusNotFound
var httpErr *HTTPError
if errors.As(err, &httpErr) {
return httpErr.Code == http.StatusNotFound
}
return false
}
func HTTPErrorf(code int, format string, a ...interface{}) *HTTPError {