Skip to content
Snippets Groups Projects
Commit 24b2338c authored by Subhan Shah's avatar Subhan Shah
Browse files

#34 Check if err is not nil in errors.HTTPWithError.

parent c46a7221
Branches
Tags
1 merge request!36Resolve "Cater for errors being nil and update checks for retryable errors"
...@@ -101,14 +101,15 @@ func HTTPCodeOnly(code int) error { ...@@ -101,14 +101,15 @@ func HTTPCodeOnly(code int) error {
} }
func HTTPWithError(code int, err error) 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. var errorMessage string
if err == nil { // This check is here just as a failsafe to seg faults, if err is nil then just return assign an empty string as message.
return nil if err != nil {
errorMessage = err.Error()
} }
wrappedErr := &CustomError{ wrappedErr := &CustomError{
code: code, code: code,
message: err.Error(), message: errorMessage,
caller: GetCaller(2), caller: GetCaller(2),
cause: err, cause: err,
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment