Skip to content

Commit

Permalink
fix cac error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
micahlmartin committed May 11, 2022
1 parent 25a344c commit 899e82d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions harness/cd/cac.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,18 @@ func (c *ConfigAsCodeClient) ExecuteRequest(request *retryablehttp.Request) (*ca

if responseObj.Resource != nil {

if responseObj.Resource.Status != "" && responseObj.Resource.Status != statusSuccess {
return nil, fmt.Errorf("%s: %s", responseObj.Resource.Status, responseObj.Resource.ErrorMessage)
}

if responseObj.Resource.ErrorMessage != "" {
return nil, fmt.Errorf("%s", responseObj.Resource.ErrorMessage)
}

if responseObj.Resource.ErrorMssg != "" {
return nil, fmt.Errorf("%s", responseObj.Resource.ErrorMssg)
}

if responseObj.Resource.Status != "" && responseObj.Resource.Status != statusSuccess {
return nil, fmt.Errorf("%s: %s", responseObj.Resource.Status, strings.Join([]string{responseObj.Resource.ErrorMessage, responseObj.Resource.ErrorMssg}, " "))
}

}

return responseObj.Resource, nil
Expand Down

0 comments on commit 899e82d

Please sign in to comment.