From 58d36c7de78a6d56104c22a707530f0b65b4d343 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 15 Sep 2020 09:39:53 +1000 Subject: [PATCH 1/2] when no data is returned from the api, print a better message and exit 0 --- cmd/get.go | 16 +++++++------- cmd/list.go | 40 ++++++++++++++++++++-------------- cmd/notificationsrocketchat.go | 10 ++++++--- cmd/notificationsslack.go | 11 +++++++--- cmd/shared.go | 2 -- cmd/users.go | 8 +++---- 6 files changed, 51 insertions(+), 36 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index 692a836c..2d6af1d1 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -64,8 +64,8 @@ var getProjectCmd = &cobra.Command{ os.Exit(1) } if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo(fmt.Sprintf("No details for project '%s'", getProjectFlags.Project), outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) @@ -89,8 +89,8 @@ var getDeploymentCmd = &cobra.Command{ os.Exit(1) } if string(returnedJSON) == "null" { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo(fmt.Sprintf("No deployment for remoteId '%s'", getProjectFlags.RemoteID), outputOptions) + os.Exit(0) } var deployment api.Deployment err = json.Unmarshal([]byte(returnedJSON), &deployment) @@ -123,8 +123,8 @@ var getEnvironmentCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo(fmt.Sprintf("No environment '%s' for project '%s'", cmdProjectEnvironment, cmdProjectName), outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) @@ -148,8 +148,8 @@ var getProjectKeyCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo(fmt.Sprintf("No project-key for project '%s'", getProjectFlags.Project), outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) diff --git a/cmd/list.go b/cmd/list.go index 4741c5d1..e8d2da77 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -50,8 +50,8 @@ var listProjectsCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo("No access to any projects in Lagoon", outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) @@ -69,8 +69,8 @@ var listGroupsCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo("This account is not in any groups", outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) @@ -101,8 +101,12 @@ var listGroupProjectsCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + if !listAllProjects { + output.RenderInfo(fmt.Sprintf("There are no projects in group '%s'", groupName), outputOptions) + } else { + output.RenderInfo("There are no projects in any groups", outputOptions) + } + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) @@ -125,8 +129,8 @@ var listProjectCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo(fmt.Sprintf("There are no environments for project '%s'", cmdProjectName), outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) @@ -156,8 +160,12 @@ var listVariablesCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + if cmdProjectEnvironment != "" { + output.RenderInfo(fmt.Sprintf("There are no variables for environment '%s' in project '%s'", cmdProjectEnvironment, cmdProjectName), outputOptions) + } else { + output.RenderInfo(fmt.Sprintf("There are no variables for project '%s'", cmdProjectName), outputOptions) + } + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) }, @@ -180,8 +188,8 @@ var listDeploymentsCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo(fmt.Sprintf("There are no deployments for environment '%s' in project '%s'", cmdProjectEnvironment, cmdProjectName), outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) }, @@ -204,8 +212,8 @@ var listTasksCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo(fmt.Sprintf("There are no tasks for environment '%s' in project '%s'", cmdProjectEnvironment, cmdProjectName), outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) }, @@ -225,8 +233,8 @@ var listUsersCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo("There are no users in any groups", outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) diff --git a/cmd/notificationsrocketchat.go b/cmd/notificationsrocketchat.go index f6c25303..cdcf3c4d 100644 --- a/cmd/notificationsrocketchat.go +++ b/cmd/notificationsrocketchat.go @@ -17,11 +17,12 @@ var listRocketChatsCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { var returnedJSON []byte var err error + var notificationFlags NotificationFlags if listAllProjects { returnedJSON, err = pClient.ListAllRocketChats() handleError(err) } else { - notificationFlags := parseNotificationFlags(*cmd.Flags()) + notificationFlags = parseNotificationFlags(*cmd.Flags()) if notificationFlags.Project == "" { fmt.Println("Missing arguments: Project name is not defined") cmd.Help() @@ -34,8 +35,11 @@ var listRocketChatsCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + if listAllProjects { + output.RenderInfo("No notifications for RocketChat", outputOptions) + } else { + output.RenderInfo(fmt.Sprintf("No notifications for RocketChat in project '%s'", notificationFlags.Project), outputOptions) + } } output.RenderOutput(dataMain, outputOptions) }, diff --git a/cmd/notificationsslack.go b/cmd/notificationsslack.go index cc8475ec..86e3cc25 100644 --- a/cmd/notificationsslack.go +++ b/cmd/notificationsslack.go @@ -17,11 +17,12 @@ var listSlackCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { var returnedJSON []byte var err error + var notificationFlags NotificationFlags if listAllProjects { returnedJSON, err = pClient.ListAllSlacks() handleError(err) } else { - notificationFlags := parseNotificationFlags(*cmd.Flags()) + notificationFlags = parseNotificationFlags(*cmd.Flags()) if notificationFlags.Project == "" { fmt.Println("Missing arguments: Project name is not defined") cmd.Help() @@ -35,8 +36,12 @@ var listSlackCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + if listAllProjects { + output.RenderInfo("No notifications for Slack", outputOptions) + } else { + output.RenderInfo(fmt.Sprintf("No notifications for Slack in project '%s'", notificationFlags.Project), outputOptions) + } + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) diff --git a/cmd/shared.go b/cmd/shared.go index 0a2760ff..3f7b0759 100644 --- a/cmd/shared.go +++ b/cmd/shared.go @@ -60,8 +60,6 @@ var outputOptions = output.Options{ var debugEnable bool -var noDataError = "no data returned from the lagoon api" - func handleError(err error) { if err != nil { output.RenderError(err.Error(), outputOptions) diff --git a/cmd/users.go b/cmd/users.go index ea6a2506..73e018cb 100644 --- a/cmd/users.go +++ b/cmd/users.go @@ -221,8 +221,8 @@ var getUserKeysCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo(fmt.Sprintf("No ssh-keys for user '%s'", userEmail), outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) @@ -242,8 +242,8 @@ var getAllUserKeysCmd = &cobra.Command{ err = json.Unmarshal([]byte(returnedJSON), &dataMain) handleError(err) if len(dataMain.Data) == 0 { - output.RenderError(noDataError, outputOptions) - os.Exit(1) + output.RenderInfo("No ssh-keys for any users", outputOptions) + os.Exit(0) } output.RenderOutput(dataMain, outputOptions) From 91e8aeeb42848bb52ad93d14305c2ba154b15cee Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 15 Sep 2020 09:46:47 +1000 Subject: [PATCH 2/2] change error for null response --- pkg/api/backups.go | 10 +++++----- pkg/api/environments.go | 10 +++++----- pkg/api/groups.go | 16 ++++++++-------- pkg/api/projects.go | 32 ++++++++++++++++---------------- pkg/api/tasks.go | 2 +- pkg/api/users.go | 12 ++++++------ 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/pkg/api/backups.go b/pkg/api/backups.go index 30e651ab..c1f78309 100644 --- a/pkg/api/backups.go +++ b/pkg/api/backups.go @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } diff --git a/pkg/api/environments.go b/pkg/api/environments.go index 94e7114d..67fd111b 100644 --- a/pkg/api/environments.go +++ b/pkg/api/environments.go @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } diff --git a/pkg/api/groups.go b/pkg/api/groups.go index 99f79cc1..1c0266e0 100644 --- a/pkg/api/groups.go +++ b/pkg/api/groups.go @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } diff --git a/pkg/api/projects.go b/pkg/api/projects.go index b576780c..eb96cea6 100644 --- a/pkg/api/projects.go +++ b/pkg/api/projects.go @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } diff --git a/pkg/api/tasks.go b/pkg/api/tasks.go index d3cc057b..d16bae70 100644 --- a/pkg/api/tasks.go +++ b/pkg/api/tasks.go @@ -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 } diff --git a/pkg/api/users.go b/pkg/api/users.go index beeb7b3e..0e52e6fb 100644 --- a/pkg/api/users.go +++ b/pkg/api/users.go @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 }