@@ -31,6 +31,9 @@ func CreateCluster(managerAddr []string, addresses []string) error {
31
31
if res .StatusCode != 200 {
32
32
var e common.Error
33
33
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
34
+ if _ , ok := err .(* json.SyntaxError ); ok {
35
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
36
+ }
34
37
return err
35
38
}
36
39
return fmt .Errorf (e .Message )
@@ -69,6 +72,9 @@ func DeleteCluster(managerAddr []string, clusterId string) error {
69
72
if res .StatusCode != 200 {
70
73
var e common.Error
71
74
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
75
+ if _ , ok := err .(* json.SyntaxError ); ok {
76
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
77
+ }
72
78
return err
73
79
}
74
80
return fmt .Errorf (e .Message )
@@ -100,6 +106,9 @@ func MoveCluster(managerAddr []string, clusterIds []string) error {
100
106
101
107
var e common.Error
102
108
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
109
+ if _ , ok := err .(* json.SyntaxError ); ok {
110
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
111
+ }
103
112
return err
104
113
}
105
114
return fmt .Errorf (e .Message )
@@ -129,6 +138,9 @@ func BalanceClusters(managerAddr []string, clusterIds []string) error {
129
138
130
139
var e common.Error
131
140
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
141
+ if _ , ok := err .(* json.SyntaxError ); ok {
142
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
143
+ }
132
144
return err
133
145
}
134
146
return fmt .Errorf (e .Message )
@@ -154,6 +166,9 @@ func AddNode(managerAddr []string, clusterId string, addresses []string) error {
154
166
if res .StatusCode != 200 {
155
167
var e common.Error
156
168
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
169
+ if _ , ok := err .(* json.SyntaxError ); ok {
170
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
171
+ }
157
172
return err
158
173
}
159
174
return fmt .Errorf (e .Message )
@@ -192,6 +207,9 @@ func RemoveNode(managerAddr []string, nodeId string) error {
192
207
if res .StatusCode != 200 {
193
208
var e common.Error
194
209
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
210
+ if _ , ok := err .(* json.SyntaxError ); ok {
211
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
212
+ }
195
213
return err
196
214
}
197
215
return fmt .Errorf (e .Message )
@@ -219,6 +237,9 @@ func Unfreeze(managerAddr []string, clusterIds []string) error {
219
237
if res .StatusCode != 200 {
220
238
var e common.Error
221
239
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
240
+ if _ , ok := err .(* json.SyntaxError ); ok {
241
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
242
+ }
222
243
return err
223
244
}
224
245
return fmt .Errorf (e .Message )
@@ -250,6 +271,9 @@ func CreateSnapshot(managerAddr []string, clusterId string) error {
250
271
251
272
var e common.Error
252
273
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
274
+ if _ , ok := err .(* json.SyntaxError ); ok {
275
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
276
+ }
253
277
return err
254
278
}
255
279
return fmt .Errorf (e .Message )
@@ -279,6 +303,9 @@ func DeleteSnapshot(managerAddr []string, clusterId string, snapshotIndex uint64
279
303
280
304
var e common.Error
281
305
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
306
+ if _ , ok := err .(* json.SyntaxError ); ok {
307
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
308
+ }
282
309
return err
283
310
}
284
311
return fmt .Errorf (e .Message )
@@ -308,6 +335,9 @@ func RestoreSnapshot(managerAddr []string, clusterId string, snapshotIndex uint6
308
335
309
336
var e common.Error
310
337
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
338
+ if _ , ok := err .(* json.SyntaxError ); ok {
339
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
340
+ }
311
341
return err
312
342
}
313
343
return fmt .Errorf (e .Message )
@@ -333,6 +363,9 @@ func SyncClusters(managerAddr []string, clusterId string, force bool) error {
333
363
if res .StatusCode != 202 {
334
364
var e common.Error
335
365
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
366
+ if _ , ok := err .(* json.SyntaxError ); ok {
367
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
368
+ }
336
369
return err
337
370
}
338
371
return fmt .Errorf (e .Message )
@@ -358,6 +391,9 @@ func RepairConsistency(managerAddr []string, repairModel string) error {
358
391
if res .StatusCode != 202 {
359
392
var e common.Error
360
393
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
394
+ if _ , ok := err .(* json.SyntaxError ); ok {
395
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
396
+ }
361
397
return err
362
398
}
363
399
return fmt .Errorf (e .Message )
@@ -383,6 +419,9 @@ func GetClusters(managerAddr []string, clusterId string) error {
383
419
if res .StatusCode != 200 {
384
420
var e common.Error
385
421
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
422
+ if _ , ok := err .(* json.SyntaxError ); ok {
423
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
424
+ }
386
425
return err
387
426
}
388
427
return fmt .Errorf (e .Message )
@@ -473,6 +512,9 @@ func GetReport(managerAddr []string) error {
473
512
if res .StatusCode != 200 {
474
513
var e common.Error
475
514
if err := json .NewDecoder (res .Body ).Decode (& e ); err != nil {
515
+ if _ , ok := err .(* json.SyntaxError ); ok {
516
+ return fmt .Errorf ("dfs manager returned with an unrecognisable status code: %d" , res .StatusCode )
517
+ }
476
518
return err
477
519
}
478
520
return fmt .Errorf (e .Message )
0 commit comments