Return remote API errors as JSON

Signed-off-by: Ben Firshman <ben@firshman.co.uk>
Upstream-commit: 322e2a7d059a81617b593cf6ece2cfd9f6d4ea03
Component: engine
This commit is contained in:
Ben Firshman
2016-05-21 12:56:04 +01:00
parent 9504e2f68b
commit ecda48bde7
13 changed files with 135 additions and 59 deletions

View File

@ -1507,3 +1507,10 @@ func waitForGoroutines(expected int) error {
}
}
}
// getErrorMessage returns the error message from an error API response
func getErrorMessage(c *check.C, body []byte) string {
var resp types.ErrorResponse
c.Assert(json.Unmarshal(body, &resp), check.IsNil)
return strings.TrimSpace(resp.Message)
}