Handle Stream() errors consistently in restclient

We should be following the same rules for Stream() as the normal body
request flow.

Also add slightly more output on a server error - in the future we may
want to clean this up but it's potentially hiding bad responses.
This commit is contained in:
Clayton Coleman
2016-09-04 14:42:30 -04:00
parent 2ead4ba589
commit 5e6f5fee8a
2 changed files with 7 additions and 17 deletions

View File

@@ -196,8 +196,10 @@ func StandardErrorMessage(err error) (string, bool) {
switch {
case isStatus:
switch s := status.Status(); {
case s.Reason == "Unauthorized":
case s.Reason == unversioned.StatusReasonUnauthorized:
return fmt.Sprintf("error: You must be logged in to the server (%s)", s.Message), true
case len(s.Reason) > 0:
return fmt.Sprintf("Error from server (%s): %s", s.Reason, err.Error()), true
default:
return fmt.Sprintf("Error from server: %s", err.Error()), true
}