Merge "Track the attempted method when raising UnsupportedVersion"

This commit is contained in:
Jenkins 2014-10-15 14:05:44 +00:00 committed by Gerrit Code Review
commit a1489a252d
2 changed files with 7 additions and 2 deletions

View File

@ -67,10 +67,13 @@ class NoSuchMethod(RPCDispatcherError, AttributeError):
class UnsupportedVersion(RPCDispatcherError):
"Raised if there is no endpoint which supports the requested version."
def __init__(self, version):
def __init__(self, version, method=None):
msg = "Endpoint does not support RPC version %s" % version
if method:
msg = "%s. Attempted method: %s" % (msg, method)
super(UnsupportedVersion, self).__init__(msg)
self.version = version
self.method = method
class RPCDispatcher(object):
@ -183,4 +186,4 @@ class RPCDispatcher(object):
if found_compatible:
raise NoSuchMethod(method)
else:
raise UnsupportedVersion(version)
raise UnsupportedVersion(version, method=method)

View File

@ -111,6 +111,8 @@ class TestDispatcher(test_utils.BaseTestCase):
elif isinstance(ex, messaging.UnsupportedVersion):
self.assertEqual(self.msg.get('version', '1.0'),
ex.version)
if ex.method:
self.assertEqual(self.msg.get('method'), ex.method)
else:
self.assertTrue(self.success, failure)
self.assertIsNone(failure)