Skip to content

Commit 1b0fb17

Browse files
authored
Print body when json parsing fails (#905)
1 parent 7c82e9b commit 1b0fb17

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

cli/cmd/cluster.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,16 @@ func cmdInfo(awsCreds AWSCredentials, accessConfig *clusterconfig.AccessConfig)
369369

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

377377
var infoResponse schema.InfoResponse
378378
err = json.Unmarshal(httpResponse, &infoResponse)
379379
if err != nil {
380-
fmt.Println(clusterConfig.UserStr())
381-
fmt.Println("\n" + errors.Message(err, "unable to parse operator response"))
380+
fmt.Println(clusterConfig.UserStr() + "\n")
381+
exit.Error(err, "/info", string(httpResponse))
382382
return
383383
}
384384
infoResponse.ClusterConfig.Config = clusterConfig

cli/cmd/get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func getAPIs() (string, error) {
7676

7777
var apisRes schema.GetAPIsResponse
7878
if err = json.Unmarshal(httpRes, &apisRes); err != nil {
79-
return "", err
79+
return "", errors.Wrap(err, "/get", string(httpRes))
8080
}
8181

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

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

105105
var out string

cli/cmd/predict.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var _predictCmd = &cobra.Command{
6666

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

7272
totalReady := apiRes.Status.Updated.Ready + apiRes.Status.Stale.Ready

0 commit comments

Comments
 (0)