summaryrefslogtreecommitdiff
path: root/heatclient/exc.py
diff options
context:
space:
mode:
authorTetiana Lashchova <tlashchova@mirantis.com>2014-12-01 17:54:08 +0200
committerTetiana Lashchova <tlashchova@mirantis.com>2014-12-10 12:25:06 +0200
commit6ff27ccabf0580d57f48e607b21535f5475ff3fe (patch)
tree032bf46d2426b7e134da7745c7d27a566b5b787f /heatclient/exc.py
parent4916c64f7fc126cbcce05055569d4ff7efb37e3a (diff)
downloadpython-heatclient-6ff27ccabf0580d57f48e607b21535f5475ff3fe.tar.gz
Add transtlation markers for error messages
Change-Id: Ic44073880b7e65b6530a7314a5a2d65eb4aadb09 Partial-Bug: #1269930
Diffstat (limited to 'heatclient/exc.py')
-rw-r--r--heatclient/exc.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/heatclient/exc.py b/heatclient/exc.py
index 1c9883d..4240d75 100644
--- a/heatclient/exc.py
+++ b/heatclient/exc.py
@@ -14,6 +14,8 @@ import sys
from oslo.serialization import jsonutils
+from heatclient.openstack.common._i18n import _
+
verbose = 0
@@ -47,7 +49,7 @@ class HTTPException(BaseException):
try:
self.error = jsonutils.loads(message)
if 'error' not in self.error:
- raise KeyError('Key "error" not exists')
+ raise KeyError(_('Key "error" not exists'))
except KeyError:
# NOTE(jianingy): If key 'error' happens not exist,
# self.message becomes no sense. In this case, we
@@ -62,19 +64,24 @@ class HTTPException(BaseException):
message = self.error['error'].get('message', 'Internal Error')
if verbose:
traceback = self.error['error'].get('traceback', '')
- return 'ERROR: %s\n%s' % (message, traceback)
+ return (_('ERROR: %(message)s\n%(traceback)s') %
+ {'message': message, 'traceback': traceback})
else:
- return 'ERROR: %s' % message
+ return _('ERROR: %s') % message
class HTTPMultipleChoices(HTTPException):
code = 300
def __str__(self):
- self.details = ("Requested version of Heat API is not"
- "available.")
- return "%s (HTTP %s) %s" % (self.__class__.__name__, self.code,
- self.details)
+ self.details = _("Requested version of Heat API is not"
+ "available.")
+ return (_("%(name)s (HTTP %(code)s) %(details)s") %
+ {
+ 'name': self.__class__.__name__,
+ 'code': self.code,
+ 'details': self.details
+ })
class BadRequest(HTTPException):