Track the attempted method when raising UnsupportedVersion
This helps in circumstances where the only stacktrace visible is on the target side (e.g. due to cast or fanout operations) and without the method information is difficult to root cause what is going on. Change-Id: I070ecda4d56186fcda8e8bfc49bf723928998393 Closes-bug: #1340277
This commit is contained in:
parent
73d6b210f3
commit
ed886236f6
@ -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…
Reference in New Issue
Block a user