Skip to content

Commit

Permalink
change error for null response
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Sep 14, 2020
1 parent 58d36c7 commit 91e8aee
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
10 changes: 5 additions & 5 deletions pkg/api/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (api *Interface) AddBackup(backup AddBackup) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func (api *Interface) DeleteBackup(backup DeleteBackup) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -101,7 +101,7 @@ func (api *Interface) UpdateRestore(update UpdateRestore) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -138,7 +138,7 @@ func (api *Interface) GetAllEnvironmentBackups() ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -179,7 +179,7 @@ func (api *Interface) GetEnvironmentBackups(backups EnvironmentBackups) ([]byte,
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
10 changes: 5 additions & 5 deletions pkg/api/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (api *Interface) GetEnvironmentByName(environment EnvironmentByName, fragme
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -94,7 +94,7 @@ func (api *Interface) AddOrUpdateEnvironment(environment AddUpdateEnvironment) (
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (api *Interface) UpdateEnvironment(environment UpdateEnvironment) ([]byte,
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -160,7 +160,7 @@ func (api *Interface) DeleteEnvironment(environment DeleteEnvironment) ([]byte,
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -194,7 +194,7 @@ func (api *Interface) SetEnvironmentServices(environment SetEnvironmentServices)
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
16 changes: 8 additions & 8 deletions pkg/api/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (api *Interface) AddGroup(group AddGroup) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func (api *Interface) AddGroupWithParent(group AddGroup) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func (api *Interface) UpdateGroup(group UpdateGroup) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -136,7 +136,7 @@ func (api *Interface) DeleteGroup(group AddGroup) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func (api *Interface) AddUserToGroup(user AddUserToGroup) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -205,7 +205,7 @@ func (api *Interface) AddGroupToProject(group ProjectToGroup) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -238,7 +238,7 @@ func (api *Interface) RemoveGroupFromProject(group ProjectToGroup) ([]byte, erro
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -272,7 +272,7 @@ func (api *Interface) RemoveUserFromGroup(user UserGroup) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
32 changes: 16 additions & 16 deletions pkg/api/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (api *Interface) GetOpenShiftInfoForProject(project Project) ([]byte, error
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func (api *Interface) AddProject(project ProjectPatch, fragment string) ([]byte,
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func (api *Interface) UpdateProject(project UpdateProject, fragment string) ([]b
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func (api *Interface) DeleteProject(project Project) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func (api *Interface) GetProductionEnvironmentForProject(project Project) ([]byt
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -234,7 +234,7 @@ func (api *Interface) GetEnvironmentByOpenshiftProjectName(environment Environme
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -271,7 +271,7 @@ func (api *Interface) GetProjectsByGitURL(project Project) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -304,7 +304,7 @@ func (api *Interface) GetProjectByName(project Project, fragment string) ([]byte
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -336,7 +336,7 @@ func (api *Interface) GetAllProjects(fragment string) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -371,7 +371,7 @@ func (api *Interface) GetRocketChatInfoForProject(project Project, fragment stri
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -406,7 +406,7 @@ func (api *Interface) GetSlackInfoForProject(project Project, fragment string) (
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -439,7 +439,7 @@ func (api *Interface) GetActiveSystemForProject(project Project, task string) ([
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -471,7 +471,7 @@ func (api *Interface) GetEnvironmentsForProject(project Project) ([]byte, error)
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -501,7 +501,7 @@ func (api *Interface) GetDeploymentByRemoteID(deployment Deployment) ([]byte, er
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -540,7 +540,7 @@ func (api *Interface) AddDeployment(deployment Deployment) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -573,7 +573,7 @@ func (api *Interface) UpdateDeployment(deployment UpdateDeployment) ([]byte, err
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
2 changes: 1 addition & 1 deletion pkg/api/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (api *Interface) UpdateTask(task UpdateTask) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
12 changes: 6 additions & 6 deletions pkg/api/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (api *Interface) AddUser(user User) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -78,7 +78,7 @@ func (api *Interface) UpdateUser(user UpdateUser) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func (api *Interface) DeleteUser(user User) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func (api *Interface) GetUserBySSHKey(sshKey SSHKeyValue) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -181,7 +181,7 @@ func (api *Interface) AddSSHKey(sshKey AddSSHKey) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}
Expand Down Expand Up @@ -211,7 +211,7 @@ func (api *Interface) DeleteSSHKey(sshKey DeleteSSHKey) ([]byte, error) {
debugResponse(jsonBytes)
}
if string(jsonBytes) == "null" {
return []byte(""), errors.New("graphql: returned null")
return []byte(""), errors.New("GraphQL API returned a null response, the requested resource may not exist, or there was an error. Use `--debug` to check what was returned")
}
return jsonBytes, nil
}

0 comments on commit 91e8aee

Please sign in to comment.