~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/message.py

Consistently raise errors from the server as ErrorFromSmartServer exceptions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import collections
18
18
from cStringIO import StringIO
19
19
 
20
 
from bzrlib import errors
 
20
from bzrlib import (
 
21
    debug,
 
22
    errors,
 
23
    )
 
24
from bzrlib.trace import mutter
21
25
 
22
26
class MessageHandler(object):
23
27
 
165
169
        self._protocol_decoder.accept_bytes(bytes)
166
170
 
167
171
    def read_response_tuple(self, expect_body=False):
168
 
        """Read a response tuple from the wire.
169
 
 
170
 
        The expect_body flag is ignored.
171
 
        """
 
172
        """Read a response tuple from the wire."""
172
173
        self._wait_for_response_args()
173
174
        if not expect_body:
174
175
            self._wait_for_response_end()
175
 
        #if self.status == 'E':
176
 
        #    xxx_translate_error() # XXX
 
176
        if 'hpss' in debug.debug_flags:
 
177
            mutter('   result:   %r', self.args)
 
178
        if self.status == 'E':
 
179
            self._wait_for_response_end()
 
180
            _translate_error(self.args)
177
181
        return tuple(self.args)
178
182
 
179
183
    def read_body_bytes(self, count=-1):
210
214
    if error_name == 'LockContention':
211
215
        raise errors.LockContention('(remote lock)')
212
216
    elif error_name == 'LockFailed':
213
 
        raise errors.LockContention(*error_args[:2])
 
217
        raise errors.LockFailed(*error_args[:2])
214
218
    else:
215
219
        raise errors.ErrorFromSmartServer(error_tuple)