Merge "Update resource type exceptions with error_code"
This commit is contained in:
commit
f7750efaed
|
@ -31,6 +31,13 @@ _FATAL_EXCEPTION_FORMAT_ERRORS = False
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# TODO(kanagaraj-manickam): Expose this to user via REST API
|
||||
ERROR_CODE_MAP = {
|
||||
'99001': _("Service %(service_name)s does not have required endpoint in "
|
||||
"service catalog for the resource type %(resource_type)s")
|
||||
}
|
||||
|
||||
|
||||
@six.python_2_unicode_compatible
|
||||
class HeatException(Exception):
|
||||
"""Base Heat Exception.
|
||||
|
@ -40,12 +47,21 @@ class HeatException(Exception):
|
|||
provided to the constructor.
|
||||
"""
|
||||
message = _("An unknown exception occurred.")
|
||||
# error_code helps to provide an unique number for a given exception
|
||||
# and is encoded in XXYYY format.
|
||||
# Here, XX - For each of the entity type like stack, resource, etc
|
||||
# an unique number will be provided. All exceptions for a entity will
|
||||
# have same XX code.
|
||||
# YYY - Specific error code for a given exception.
|
||||
error_code = None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.kwargs = kwargs
|
||||
|
||||
try:
|
||||
if self.error_code in ERROR_CODE_MAP:
|
||||
self.msg_fmt = ERROR_CODE_MAP[self.error_code]
|
||||
|
||||
self.message = self.msg_fmt % kwargs
|
||||
|
||||
if self.error_code:
|
||||
|
@ -212,6 +228,10 @@ class InvalidGlobalResource(HeatException):
|
|||
"resource type %(type_name)s.")
|
||||
|
||||
|
||||
class ResourceTypeUnavailable(HeatException):
|
||||
error_code = '99001'
|
||||
|
||||
|
||||
class InvalidBreakPointHook(HeatException):
|
||||
msg_fmt = _("%(message)s")
|
||||
|
||||
|
@ -446,10 +466,5 @@ class SIGHUPInterrupt(HeatException):
|
|||
msg_fmt = _("System SIGHUP signal received.")
|
||||
|
||||
|
||||
class ResourceTypeUnavailable(HeatException):
|
||||
msg_fmt = _("Service %(service_name)s does not have required endpoint in "
|
||||
"service catalog for the resource type %(resource_type)s")
|
||||
|
||||
|
||||
class NoActionRequired(Exception):
|
||||
pass
|
||||
|
|
|
@ -167,8 +167,8 @@ class ResourceTypeTest(common.HeatTestCase):
|
|||
self.ctx,
|
||||
type_name)
|
||||
|
||||
msg = ('Service sample does not have required endpoint in service'
|
||||
' catalog for the resource type'
|
||||
msg = ('HEAT-E99001 Service sample does not have required endpoint'
|
||||
' in service catalog for the resource type'
|
||||
' ResourceWithDefaultClientName')
|
||||
self.assertEqual(msg,
|
||||
six.text_type(ex),
|
||||
|
|
|
@ -3265,8 +3265,9 @@ class ResourceAvailabilityTest(common.HeatTestCase):
|
|||
definition=definition,
|
||||
stack=mock_stack)
|
||||
|
||||
msg = ('Service sample does not have required endpoint in service'
|
||||
' catalog for the resource type UnavailableResourceType')
|
||||
msg = ('HEAT-E99001 Service sample does not have required endpoint'
|
||||
' in service catalog for the resource type'
|
||||
' UnavailableResourceType')
|
||||
self.assertEqual(msg,
|
||||
six.text_type(ex),
|
||||
'invalid exception message')
|
||||
|
|
Loading…
Reference in New Issue