Merge pull request #275 from vbnmmnbv/KmipOperationFailure

Modify KmipOperationFailure to expose status/reason/message attributes
This commit is contained in:
Peter Hamilton 2017-04-06 08:54:16 -04:00 committed by GitHub
commit 28e1e809d1
2 changed files with 10 additions and 3 deletions
kmip

@ -39,7 +39,8 @@ class KmipOperationFailure(Exception):
"""
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:
status: a ResultStatus enumeration
@ -48,3 +49,6 @@ class KmipOperationFailure(Exception):
"""
msg = "{0}: {1} - {2}".format(status.name, reason.name, message)
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):
"""
Test that a KmipOperationFailure exception message can be set
properly.
Test that a KmipOperationFailure exception message and attributes can
be set properly.
"""
status = ResultStatus.OPERATION_FAILED
reason = ResultReason.GENERAL_FAILURE
@ -104,3 +104,6 @@ class TestKmipOperationFailure(TestCase):
status.name, reason.name, "Test error message.")
self.assertEqual(msg, str(exc))
self.assertEqual(status, exc.status)
self.assertEqual(reason, exc.reason)
self.assertEqual("Test error message.", exc.message)