From 7e80a0c41b687618586162fd81f3daeab57ccfb3 Mon Sep 17 00:00:00 2001 From: Tetiana Lashchova Date: Thu, 22 Jan 2015 11:52:55 +0200 Subject: [PATCH] Add error code to APIException Change-Id: I6663d5713d90651ee3623deafbcec3bde3eea506 Closes-bug: #1412486 --- mistralclient/api/base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mistralclient/api/base.py b/mistralclient/api/base.py index 8db4162c..fd2951ef 100644 --- a/mistralclient/api/base.py +++ b/mistralclient/api/base.py @@ -134,7 +134,8 @@ class ResourceManager(object): error_data = get_json(resp).get("faultstring") except ValueError: error_data = resp.content - raise APIException(error_data) + raise APIException(error_code=resp.status_code, + error_message=error_data) def get_json(response): @@ -152,4 +153,7 @@ def get_json(response): class APIException(Exception): - pass + def __init__(self, error_code=None, error_message=None): + super(APIException, self).__init__(error_message) + self.error_code = error_code + self.error_message = error_message