mirror of https://github.com/OpenKMIP/PyKMIP.git
Modify KmipOperationFailure to expose status/reason/message attributes
This commit is contained in:
parent
2aabad714a
commit
16d79283f2
|
@ -39,7 +39,8 @@ class KmipOperationFailure(Exception):
|
||||||
"""
|
"""
|
||||||
def __init__(self, status, reason, message):
|
def __init__(self, status, reason, message):
|
||||||
"""
|
"""
|
||||||
Construct the error message for the KMIP operation failure.
|
Construct the error message and attributes for the KMIP operation
|
||||||
|
failure.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
status: a ResultStatus enumeration
|
status: a ResultStatus enumeration
|
||||||
|
@ -48,3 +49,6 @@ class KmipOperationFailure(Exception):
|
||||||
"""
|
"""
|
||||||
msg = "{0}: {1} - {2}".format(status.name, reason.name, message)
|
msg = "{0}: {1} - {2}".format(status.name, reason.name, message)
|
||||||
super(KmipOperationFailure, self).__init__(msg)
|
super(KmipOperationFailure, self).__init__(msg)
|
||||||
|
self.status = status
|
||||||
|
self.reason = reason
|
||||||
|
self.message = message
|
||||||
|
|
|
@ -93,8 +93,8 @@ class TestKmipOperationFailure(TestCase):
|
||||||
|
|
||||||
def test_message(self):
|
def test_message(self):
|
||||||
"""
|
"""
|
||||||
Test that a KmipOperationFailure exception message can be set
|
Test that a KmipOperationFailure exception message and attributes can
|
||||||
properly.
|
be set properly.
|
||||||
"""
|
"""
|
||||||
status = ResultStatus.OPERATION_FAILED
|
status = ResultStatus.OPERATION_FAILED
|
||||||
reason = ResultReason.GENERAL_FAILURE
|
reason = ResultReason.GENERAL_FAILURE
|
||||||
|
@ -104,3 +104,6 @@ class TestKmipOperationFailure(TestCase):
|
||||||
status.name, reason.name, "Test error message.")
|
status.name, reason.name, "Test error message.")
|
||||||
|
|
||||||
self.assertEqual(msg, str(exc))
|
self.assertEqual(msg, str(exc))
|
||||||
|
self.assertEqual(status, exc.status)
|
||||||
|
self.assertEqual(reason, exc.reason)
|
||||||
|
self.assertEqual("Test error message.", exc.message)
|
||||||
|
|
Loading…
Reference in New Issue