Error class can accept message with format characters
Since the Error class is designed to simply accept any message string, treating the message text as a format string causes errors if the error message has format characters. This changes Error to have its own format string that just echos the passed in message. Change-Id: I1161d5e177dff860e180f845405d536e18222b23 Closes-Bug: 1361471
This commit is contained in:
parent
f96cecfa4b
commit
86809acb61
@ -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