Avoid referencing Message.__str__ in exceptions
Change exception.py to accommodate future enablement of lazy translation. Specifically, encode unicode messages to byte strings as gettextutil.Message doesn't support __str__. Change-Id: I16ab67c32d2050d83c1b51b84b24c0a60675aff7
This commit is contained in:
parent
ca90c984ec
commit
d46adc1d53
|
@ -120,11 +120,14 @@ class HeatException(Exception):
|
||||||
raise exc_info[0], exc_info[1], exc_info[2]
|
raise exc_info[0], exc_info[1], exc_info[2]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.message)
|
return unicode(self.message).encode('UTF-8')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return unicode(self.message)
|
return unicode(self.message)
|
||||||
|
|
||||||
|
def __deepcopy__(self, memo):
|
||||||
|
return self.__class__(**self.kwargs)
|
||||||
|
|
||||||
|
|
||||||
class MissingCredentialError(HeatException):
|
class MissingCredentialError(HeatException):
|
||||||
msg_fmt = _("Missing required credential: %(required)s")
|
msg_fmt = _("Missing required credential: %(required)s")
|
||||||
|
|
|
@ -22,7 +22,7 @@ from heat.engine import resources
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
|
|
||||||
|
|
||||||
class InvalidSchemaError(Exception):
|
class InvalidSchemaError(exception.Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from heat.common import exception
|
||||||
from heat.common import identifier
|
from heat.common import identifier
|
||||||
from heat.engine import constraints
|
from heat.engine import constraints
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
|
@ -126,13 +127,13 @@ class UpdateWaitConditionHandle(WaitConditionHandle):
|
||||||
raise resource.UpdateReplace(self.name)
|
raise resource.UpdateReplace(self.name)
|
||||||
|
|
||||||
|
|
||||||
class WaitConditionFailure(Exception):
|
class WaitConditionFailure(exception.Error):
|
||||||
def __init__(self, wait_condition, handle):
|
def __init__(self, wait_condition, handle):
|
||||||
reasons = handle.get_status_reason(STATUS_FAILURE)
|
reasons = handle.get_status_reason(STATUS_FAILURE)
|
||||||
super(WaitConditionFailure, self).__init__(reasons)
|
super(WaitConditionFailure, self).__init__(reasons)
|
||||||
|
|
||||||
|
|
||||||
class WaitConditionTimeout(Exception):
|
class WaitConditionTimeout(exception.Error):
|
||||||
def __init__(self, wait_condition, handle):
|
def __init__(self, wait_condition, handle):
|
||||||
reasons = handle.get_status_reason(STATUS_SUCCESS)
|
reasons = handle.get_status_reason(STATUS_SUCCESS)
|
||||||
vals = {'len': len(reasons),
|
vals = {'len': len(reasons),
|
||||||
|
|
|
@ -91,10 +91,11 @@ class ExceptionGroup(Exception):
|
||||||
self.exceptions = list(exceptions)
|
self.exceptions = list(exceptions)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(map(str, self.exceptions))
|
return unicode([unicode(ex).encode('utf-8')
|
||||||
|
for ex in self.exceptions]).encode('utf-8')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return unicode(map(str, self.exceptions))
|
return unicode(map(unicode, self.exceptions))
|
||||||
|
|
||||||
|
|
||||||
class TaskRunner(object):
|
class TaskRunner(object):
|
||||||
|
|
Loading…
Reference in New Issue