Skip to content

Commit f852d1f

Browse files
authored
Merge pull request #26 from timperrett/lb-msg
Make the error messaging better
2 parents 0ef3429 + ccbb293 commit f852d1f

File tree

1 file changed

+19
-4
lines changed
  • src/github.com/getnelson/nelson

1 file changed

+19
-4
lines changed

src/github.com/getnelson/nelson/lbs.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,16 @@ func RemoveLoadBalancer(guid string, http *gorequest.SuperAgent, cfg *Config) (s
211211
return "", errs
212212
}
213213

214-
if r.StatusCode/100 != 2 {
214+
rcode := r.StatusCode / 100
215+
if rcode != 2 {
215216
resp := string(body[:])
216-
errs = append(errs, errors.New("Unexpected response from Nelson server"))
217+
if rcode == 4 {
218+
errs = append(errs, errors.New("The request was invalid: "+resp))
219+
} else if rcode == 5 {
220+
errs = append(errs, errors.New("Nelson server appears to be having trouble completing this request. Please seek assistance from an administrator. "+resp))
221+
} else {
222+
errs = append(errs, errors.New("Unexpected response from Nelson server"))
223+
}
217224
return resp, errs
218225
} else {
219226
return "Requested removal of " + guid, errs
@@ -230,9 +237,17 @@ func CreateLoadBalancer(req LoadbalancerCreate, http *gorequest.SuperAgent, cfg
230237
return "", errs
231238
}
232239

233-
if r.StatusCode/100 != 2 {
240+
rcode := r.StatusCode / 100
241+
if rcode != 2 {
234242
resp := string(body[:])
235-
errs = append(errs, errors.New("Unexpected response from Nelson server"))
243+
if rcode == 4 {
244+
errs = append(errs, errors.New("The request was invalid: "+resp))
245+
} else if rcode == 5 {
246+
errs = append(errs, errors.New("Nelson server appears to be having trouble completing this request. Please seek assistance from an administrator. "+resp))
247+
} else {
248+
errs = append(errs, errors.New("Unexpected response from Nelson server"))
249+
}
250+
236251
return resp, errs
237252
} else {
238253
return "Loadbalancer has been created.", errs

0 commit comments

Comments
 (0)