Merge "Track the attempted method when raising UnsupportedVersion"
This commit is contained in:
commit
a1489a252d
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user