From c35bb16b8bf0aa8be522f582ba3e79337f3a7ffb Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Fri, 23 May 2014 17:01:49 +0400 Subject: [PATCH] Handle error from upload definition command Partially closes bug: #1322421 Change-Id: I67a525856fa2b80a7f9624b448352b0438141a98 --- mistralclient/api/workbooks.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mistralclient/api/workbooks.py b/mistralclient/api/workbooks.py index eeffa6dd..8701df11 100644 --- a/mistralclient/api/workbooks.py +++ b/mistralclient/api/workbooks.py @@ -62,12 +62,19 @@ class WorkbookManager(base.ResourceManager): def upload_definition(self, name, text): self._ensure_not_empty(name=name) - self.client.http_client.put('/workbooks/%s/definition' % name, - text, - headers={'content-type': 'text/plain'}) + resp = self.client.http_client.put('/workbooks/%s/definition' % name, + text, + headers={'content-type': + 'text/plain'}) + + if resp.status_code != 200: + self._raise_api_exception(resp) def get_definition(self, name): self._ensure_not_empty(name=name) - return self.client.http_client.get('/workbooks/%s/definition' - % name).content + resp = self.client.http_client.get('/workbooks/%s/definition' + % name) + if resp.status_code != 200: + self._raise_api_exception(resp) + return resp.content