Skip to content

Print body when json parsing fails #905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cli/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,16 @@ func cmdInfo(awsCreds AWSCredentials, accessConfig *clusterconfig.AccessConfig)

httpResponse, err := HTTPGet("/info")
if err != nil {
fmt.Println(clusterConfig.UserStr())
fmt.Println("\n" + errors.Message(err, "unable to connect to operator"))
fmt.Println(clusterConfig.UserStr() + "\n")
exit.Error(err, "unable to connect to operator", "/info")
return
}

var infoResponse schema.InfoResponse
err = json.Unmarshal(httpResponse, &infoResponse)
if err != nil {
fmt.Println(clusterConfig.UserStr())
fmt.Println("\n" + errors.Message(err, "unable to parse operator response"))
fmt.Println(clusterConfig.UserStr() + "\n")
exit.Error(err, "/info", string(httpResponse))
return
}
infoResponse.ClusterConfig.Config = clusterConfig
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func getAPIs() (string, error) {

var apisRes schema.GetAPIsResponse
if err = json.Unmarshal(httpRes, &apisRes); err != nil {
return "", err
return "", errors.Wrap(err, "/get", string(httpRes))
}

if len(apisRes.APIs) == 0 {
Expand All @@ -99,7 +99,7 @@ func getAPI(apiName string) (string, error) {

var apiRes schema.GetAPIResponse
if err = json.Unmarshal(httpRes, &apiRes); err != nil {
return "", err
return "", errors.Wrap(err, "/get/"+apiName, string(httpRes))
}

var out string
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var _predictCmd = &cobra.Command{

var apiRes schema.GetAPIResponse
if err = json.Unmarshal(httpRes, &apiRes); err != nil {
exit.Error(err)
exit.Error(err, "/get"+apiName, string(httpRes))
}

totalReady := apiRes.Status.Updated.Ready + apiRes.Status.Stale.Ready
Expand Down