Skip to content

Commit

Permalink
Support new server 7.1 info command error response strings
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn committed Jun 18, 2024
1 parent 9d59955 commit f5e091b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ func parseIndexErrorCode(response string) types.ResultCode {
var code = types.OK

list := strings.Split(response, ":")
if len(list) >= 2 && list[0] == "FAIL" {
if len(list) >= 2 && (list[0] == "FAIL" || list[0] == "ERROR") {
i, err := strconv.ParseInt(list[1], 10, 64)
if err == nil {
code = types.ResultCode(i)
Expand Down Expand Up @@ -1296,7 +1296,7 @@ func (clnt *Client) CreateComplexIndex(
return NewIndexTask(clnt.cluster, namespace, indexName), nil
}

if strings.HasPrefix(response, "FAIL:200") {
if parseIndexErrorCode(response) == types.INDEX_FOUND {
// Index has already been created. Do not need to poll for completion.
return nil, newError(types.INDEX_FOUND)
}
Expand Down Expand Up @@ -1339,7 +1339,7 @@ func (clnt *Client) DropIndex(
return <-task.OnComplete()
}

if strings.HasPrefix(response, "FAIL:201") {
if parseIndexErrorCode(response) == types.INDEX_NOTFOUND {
// Index did not previously exist. Return without error.
return nil
}
Expand Down

0 comments on commit f5e091b

Please sign in to comment.