Skip to content

Commit

Permalink
Merge pull request #26 from timperrett/lb-msg
Browse files Browse the repository at this point in the history
Make the error messaging better
  • Loading branch information
timperrett authored Jan 25, 2019
2 parents 0ef3429 + ccbb293 commit f852d1f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/github.com/getnelson/nelson/lbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,16 @@ func RemoveLoadBalancer(guid string, http *gorequest.SuperAgent, cfg *Config) (s
return "", errs
}

if r.StatusCode/100 != 2 {
rcode := r.StatusCode / 100
if rcode != 2 {
resp := string(body[:])
errs = append(errs, errors.New("Unexpected response from Nelson server"))
if rcode == 4 {
errs = append(errs, errors.New("The request was invalid: "+resp))
} else if rcode == 5 {
errs = append(errs, errors.New("Nelson server appears to be having trouble completing this request. Please seek assistance from an administrator. "+resp))
} else {
errs = append(errs, errors.New("Unexpected response from Nelson server"))
}
return resp, errs
} else {
return "Requested removal of " + guid, errs
Expand All @@ -230,9 +237,17 @@ func CreateLoadBalancer(req LoadbalancerCreate, http *gorequest.SuperAgent, cfg
return "", errs
}

if r.StatusCode/100 != 2 {
rcode := r.StatusCode / 100
if rcode != 2 {
resp := string(body[:])
errs = append(errs, errors.New("Unexpected response from Nelson server"))
if rcode == 4 {
errs = append(errs, errors.New("The request was invalid: "+resp))
} else if rcode == 5 {
errs = append(errs, errors.New("Nelson server appears to be having trouble completing this request. Please seek assistance from an administrator. "+resp))
} else {
errs = append(errs, errors.New("Unexpected response from Nelson server"))
}

return resp, errs
} else {
return "Loadbalancer has been created.", errs
Expand Down

0 comments on commit f852d1f

Please sign in to comment.