From 697404cbbf97bec965f916edb2ef188c78b58cf3 Mon Sep 17 00:00:00 2001 From: Subhan Shah <subhan@uafrica.com> Date: Thu, 3 Nov 2022 15:27:55 +0200 Subject: [PATCH] #34 Check if err is nil in errors.HTTPWithError. --- errors/errors.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/errors/errors.go b/errors/errors.go index 678c54b..44dbf8f 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -101,6 +101,11 @@ func HTTPCodeOnly(code int) error { } func HTTPWithError(code int, err error) error { + // This check is here just as a failsafe, if err is nil then just return nil because there's nothing that happened. + if err == nil { + return nil + } + wrappedErr := &CustomError{ code: code, message: err.Error(), -- GitLab