Skip to content

Commit 6225574

Browse files
Merge pull request #80 from jonathanheaden/master
Add logic to not return error in DeleteUser when no user is found
2 parents 2a435e4 + 0d696c4 commit 6225574

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

client/user.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package client
33
import (
44
"fmt"
55
"log"
6+
"strings"
67
)
78

89
type Credentials struct {
@@ -263,10 +264,15 @@ func (client *Client) DeleteUser(userName string) error {
263264
Method: "DELETE",
264265
}
265266

266-
_, err := client.RequestAPI(&opts)
267-
if err != nil {
268-
return err
269-
}
267+
// The API will return a 500 error if the user cannot be found
268+
// In this case the DeleteUser function should not return an error.
269+
// Return error only if the body of the return message does not contain "User does not exist"
270+
res, err := client.RequestAPI(&opts)
271+
if err != nil {
272+
if !strings.Contains(string(res), "User does not exist") {
273+
return err
274+
}
275+
}
270276

271277
return nil
272278
}

0 commit comments

Comments
 (0)