Rev 3695: Do not traceback on unexpected error responses from a smart server. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Sat Sep 6 11:25:47 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3695
revision-id: pqm at pqm.ubuntu.com-20080906102539-ss1fkx2csdcalqlc
parent: pqm at pqm.ubuntu.com-20080905215441-14uu1ybru8397sy2
parent: andrew.bennetts at canonical.com-20080906095218-9k920hp0t6h9bif0
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2008-09-06 11:25:39 +0100
message:
Do not traceback on unexpected error responses from a smart server.
(Andrew Bennetts)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 3690.1.2
revision-id: andrew.bennetts at canonical.com-20080906095218-9k920hp0t6h9bif0
parent: andrew.bennetts at canonical.com-20080905055253-lxvnx1ga91wxrxyj
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: nicer-error
timestamp: Sat 2008-09-06 19:52:18 +1000
message:
Rename UntranslateableErrorFromSmartServer -> UnknownErrorFromSmartServer.
modified:
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 3690.1.1
revision-id: andrew.bennetts at canonical.com-20080905055253-lxvnx1ga91wxrxyj
parent: pqm at pqm.ubuntu.com-20080904180441-gssfmn0j6yw2vi0e
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: nicer-error
timestamp: Fri 2008-09-05 15:52:53 +1000
message:
Unexpected error responses from a smart server no longer cause the client to traceback.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'NEWS'
--- a/NEWS 2008-09-05 21:54:41 +0000
+++ b/NEWS 2008-09-06 10:25:39 +0000
@@ -100,6 +100,9 @@
check and test for parsing a dirstate with invalid trailing data.
(John Arbash Meinel, #186014)
+ * Unexpected error responses from a smart server no longer cause the
+ client to traceback. (Andrew Bennetts, #263527)
+
* Use a Windows api function to get a Unicode host name, rather than
assuming the host name is ascii.
(Mark Hammond, John Arbash Meinel, #256550)
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2008-09-02 18:51:03 +0000
+++ b/bzrlib/errors.py 2008-09-06 09:52:18 +0000
@@ -2508,6 +2508,10 @@
class ErrorFromSmartServer(BzrError):
+ """An error was received from a smart server.
+
+ :seealso: UnknownErrorFromSmartServer
+ """
_fmt = "Error received from smart server: %(error_tuple)r"
@@ -2522,6 +2526,32 @@
self.error_args = error_tuple[1:]
+class UnknownErrorFromSmartServer(BzrError):
+ """An ErrorFromSmartServer could not be translated into a typical bzrlib
+ error.
+
+ This is distinct from ErrorFromSmartServer so that it is possible to
+ distinguish between the following two cases:
+ - ErrorFromSmartServer was uncaught. This is logic error in the client
+ and so should provoke a traceback to the user.
+ - ErrorFromSmartServer was caught but its error_tuple could not be
+ translated. This is probably because the server sent us garbage, and
+ should not provoke a traceback.
+ """
+
+ _fmt = "Server sent an unexpected error: %(error_tuple)r"
+
+ internal_error = False
+
+ def __init__(self, error_from_smart_server):
+ """Constructor.
+
+ :param error_from_smart_server: An ErrorFromSmartServer instance.
+ """
+ self.error_from_smart_server = error_from_smart_server
+ self.error_tuple = error_from_smart_server.error_tuple
+
+
class ContainerError(BzrError):
"""Base class of container errors."""
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2008-09-05 10:25:40 +0000
+++ b/bzrlib/remote.py 2008-09-06 10:25:39 +0000
@@ -1717,6 +1717,9 @@
- bzrdir
- token
- other_branch
+
+ If the error from the server doesn't match a known pattern, then
+ UnknownErrorFromSmartServer is raised.
"""
def find(name):
try:
@@ -1744,5 +1747,5 @@
raise errors.DivergedBranches(find('branch'), find('other_branch'))
elif err.error_verb == 'TipChangeRejected':
raise errors.TipChangeRejected(err.error_args[0].decode('utf8'))
- raise
+ raise errors.UnknownErrorFromSmartServer(err)
=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py 2008-09-02 18:51:03 +0000
+++ b/bzrlib/tests/test_errors.py 2008-09-06 09:52:18 +0000
@@ -548,6 +548,19 @@
'Tip change rejected: Unicode message\xe2\x80\xbd',
str(err))
+ def test_error_from_smart_server(self):
+ error_tuple = ('error', 'tuple')
+ err = errors.ErrorFromSmartServer(error_tuple)
+ self.assertEquals(
+ "Error received from smart server: ('error', 'tuple')", str(err))
+
+ def test_untranslateable_error_from_smart_server(self):
+ error_tuple = ('error', 'tuple')
+ orig_err = errors.ErrorFromSmartServer(error_tuple)
+ err = errors.UnknownErrorFromSmartServer(orig_err)
+ self.assertEquals(
+ "Server sent an unexpected error: ('error', 'tuple')", str(err))
+
class PassThroughError(errors.BzrError):
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2008-09-05 10:48:03 +0000
+++ b/bzrlib/tests/test_remote.py 2008-09-06 10:25:39 +0000
@@ -704,7 +704,7 @@
client._calls = []
err = self.assertRaises(
- errors.ErrorFromSmartServer,
+ errors.UnknownErrorFromSmartServer,
branch.set_last_revision_info, 123, 'revid')
self.assertEqual(('UnexpectedError',), err.error_tuple)
branch.unlock()
@@ -1080,7 +1080,7 @@
transport_path = 'sinhala'
repo, client = self.setup_fake_client_and_repository(transport_path)
client.add_error_response('AnUnexpectedError')
- e = self.assertRaises(errors.ErrorFromSmartServer,
+ e = self.assertRaises(errors.UnknownErrorFromSmartServer,
self.applyDeprecated, one_four, repo.get_revision_graph, revid)
self.assertEqual(('AnUnexpectedError',), e.error_tuple)
@@ -1350,7 +1350,8 @@
error_tuple = ('An unknown error tuple',)
server_error = errors.ErrorFromSmartServer(error_tuple)
translated_error = self.translateErrorFromSmartServer(server_error)
- self.assertEqual(server_error, translated_error)
+ expected_error = errors.UnknownErrorFromSmartServer(server_error)
+ self.assertEqual(expected_error, translated_error)
def test_context_missing_a_key(self):
"""In case of a bug in the client, or perhaps an unexpected response
More information about the bazaar-commits
mailing list