Merge "Error class can accept message with format characters"
This commit is contained in:
commit
227e84dc30
@ -324,9 +324,10 @@ class EgressRuleNotAllowed(HeatException):
|
||||
|
||||
|
||||
class Error(HeatException):
|
||||
def __init__(self, msg_fmt):
|
||||
self.msg_fmt = msg_fmt
|
||||
super(Error, self).__init__()
|
||||
msg_fmt = "%(message)s"
|
||||
|
||||
def __init__(self, msg):
|
||||
super(Error, self).__init__(message=msg)
|
||||
|
||||
|
||||
class NotFound(HeatException):
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
import fixtures
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.tests import common
|
||||
@ -32,3 +33,8 @@ class TestHeatException(common.HeatTestCase):
|
||||
'heat.common.exception._FATAL_EXCEPTION_FORMAT_ERRORS',
|
||||
True))
|
||||
self.assertRaises(KeyError, TestException)
|
||||
|
||||
def test_format_string_error_message(self):
|
||||
message = "This format %(message)s should work"
|
||||
err = exception.Error(message)
|
||||
self.assertEqual(message, six.text_type(err))
|
||||
|
Loading…
Reference in New Issue
Block a user