Mercurial > public > mercurial-scm > hg
comparison mercurial/wireprotov2peer.py @ 39486:43d92d68ac88
wireprotov2peer: properly format errors
formatrichmessage() expects an iterable containing dicts with
well-defined keys. We were passing in something else. This caused
an exception.
Change the code to call formatrichmessage() with the proper argument.
And add a TODO to potentially emit the proper data structure from
the server in the first place.
Differential Revision: https://phab.mercurial-scm.org/D4441
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 05 Sep 2018 09:04:40 -0700 |
parents | 42bc1c70a6b8 |
children | 07b58266bce3 |
comparison
equal
deleted
inserted
replaced
39485:42bc1c70a6b8 | 39486:43d92d68ac88 |
---|---|
25 | 25 |
26 for atom in atoms: | 26 for atom in atoms: |
27 msg = _(atom[b'msg']) | 27 msg = _(atom[b'msg']) |
28 | 28 |
29 if b'args' in atom: | 29 if b'args' in atom: |
30 msg = msg % atom[b'args'] | 30 msg = msg % tuple(atom[b'args']) |
31 | 31 |
32 chunks.append(msg) | 32 chunks.append(msg) |
33 | 33 |
34 return b''.join(chunks) | 34 return b''.join(chunks) |
35 | 35 |
161 overall = next(objs) | 161 overall = next(objs) |
162 | 162 |
163 if overall['status'] == 'ok': | 163 if overall['status'] == 'ok': |
164 self._futures[frame.requestid].set_result(decoder(objs)) | 164 self._futures[frame.requestid].set_result(decoder(objs)) |
165 else: | 165 else: |
166 e = error.RepoError( | 166 atoms = [{'msg': overall['error']['message']}] |
167 formatrichmessage(overall['error']['message'])) | 167 if 'args' in overall['error']: |
168 atoms[0]['args'] = overall['error']['args'] | |
169 e = error.RepoError(formatrichmessage(atoms)) | |
168 self._futures[frame.requestid].set_exception(e) | 170 self._futures[frame.requestid].set_exception(e) |
169 else: | 171 else: |
170 self._futures[frame.requestid].set_result(response) | 172 self._futures[frame.requestid].set_result(response) |
171 | 173 |
172 del self._requests[frame.requestid] | 174 del self._requests[frame.requestid] |