Skip to content

Commit

Permalink
Merge pull request #37 from permitio/raz/per-9675-panic-in-go-issue
Browse files Browse the repository at this point in the history
handling err nil in NewPermitUnprocessableEntityError
  • Loading branch information
RazcoDev authored Apr 15, 2024
2 parents 37bf6ff + 5c3073c commit 9392959
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,13 @@ func NewPermitPaginationError() PermitError {
}

func NewPermitUnprocessableEntityError(err error, response *http.Response) PermitError {
errorMessage := ErrorMessage(err.Error())

if err == nil {
errorMessage = UnprocessableEntityMessage
return NewPermitError(UnprocessableEntityMessage, UnprocessableEntityError, API_ERROR, response)
}

errorMessage := ErrorMessage(err.Error())
if strings.Contains(err.Error(), "not a valid email address") {
errorMessage = "Email is not valid"
}

return NewPermitError(errorMessage, UnprocessableEntityError, API_ERROR, response)
}

Expand Down

0 comments on commit 9392959

Please sign in to comment.