Remove "message" attribute support from IronicException
This was deprecated last August, go ahead and remove it. Change-Id: Iabb3950cf958aaa800688d9f7aa1c2d3673c7f6f
This commit is contained in:
parent
4da99c1976
commit
7054e289f7
@ -27,7 +27,6 @@ from six.moves import http_client
|
|||||||
|
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
from ironic.common.i18n import _LE
|
from ironic.common.i18n import _LE
|
||||||
from ironic.common.i18n import _LW
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -71,15 +70,6 @@ class IronicException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if not message:
|
if not message:
|
||||||
# Check if class is using deprecated 'message' attribute.
|
|
||||||
if (hasattr(self, 'message') and self.message):
|
|
||||||
LOG.warning(_LW("Exception class: %s Using the 'message' "
|
|
||||||
"attribute in an exception has been "
|
|
||||||
"deprecated. The exception class should be "
|
|
||||||
"modified to use the '_msg_fmt' "
|
|
||||||
"attribute."), self.__class__.__name__)
|
|
||||||
self._msg_fmt = self.message
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
message = self._msg_fmt % kwargs
|
message = self._msg_fmt % kwargs
|
||||||
|
|
||||||
|
@ -12,17 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.tests import base
|
from ironic.tests import base
|
||||||
|
|
||||||
|
|
||||||
class DeprecatedException(exception.IronicException):
|
|
||||||
message = 'Using message is deprecated %(foo)s'
|
|
||||||
|
|
||||||
|
|
||||||
class TestIronicException(base.TestCase):
|
class TestIronicException(base.TestCase):
|
||||||
def test____init__(self):
|
def test____init__(self):
|
||||||
expected = b'\xc3\xa9\xe0\xaf\xb2\xe0\xbe\x84'
|
expected = b'\xc3\xa9\xe0\xaf\xb2\xe0\xbe\x84'
|
||||||
@ -33,13 +28,3 @@ class TestIronicException(base.TestCase):
|
|||||||
message = unichr(233) + unichr(0x0bf2) + unichr(3972)
|
message = unichr(233) + unichr(0x0bf2) + unichr(3972)
|
||||||
exc = exception.IronicException(message)
|
exc = exception.IronicException(message)
|
||||||
self.assertEqual(expected, exc.__str__())
|
self.assertEqual(expected, exc.__str__())
|
||||||
|
|
||||||
@mock.patch.object(exception.LOG, 'warning', autospec=True)
|
|
||||||
def test_message_deprecated(self, mock_logw):
|
|
||||||
exc = DeprecatedException(foo='spam')
|
|
||||||
mock_logw.assert_called_once_with(
|
|
||||||
"Exception class: %s Using the 'message' "
|
|
||||||
"attribute in an exception has been deprecated. The exception "
|
|
||||||
"class should be modified to use the '_msg_fmt' attribute.",
|
|
||||||
'DeprecatedException')
|
|
||||||
self.assertEqual('Using message is deprecated spam', str(exc))
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- Removes support for the "message" attribute from the
|
||||||
|
"IronicException" class. Subclasses of "IronicException"
|
||||||
|
should instead use the "_msg_fmt" attribute.
|
||||||
|
This change is only relevant to developers.
|
Loading…
Reference in New Issue
Block a user