##// END OF EJS Templates
lfs: improve the client message when the server signals an object error...
Matt Harbison -
r37259:67db8484 default
parent child Browse files
Show More
@@ -263,23 +263,34 b' class _gitlfsremote(object):'
263 # server implementation (ex. lfs-test-server) does not set "error"
263 # server implementation (ex. lfs-test-server) does not set "error"
264 # but just removes "download" from "actions". Treat that case
264 # but just removes "download" from "actions". Treat that case
265 # as the same as 404 error.
265 # as the same as 404 error.
266 notfound = (response.get('error', {}).get('code') == 404
266 if 'error' not in response:
267 or (action == 'download'
267 if (action == 'download'
268 and action not in response.get('actions', [])))
268 and action not in response.get('actions', [])):
269 if notfound:
269 code = 404
270 ptrmap = {p.oid(): p for p in pointers}
271 p = ptrmap.get(response['oid'], None)
272 if p:
273 filename = getattr(p, 'filename', 'unknown')
274 raise LfsRemoteError(
275 _(('LFS server error. Remote object '
276 'for "%s" not found: %r')) % (filename, response))
277 else:
270 else:
278 raise LfsRemoteError(
271 continue
279 _('LFS server error. Unsolicited response for oid %s')
272 else:
280 % response['oid'])
273 # An error dict without a code doesn't make much sense, so
281 if 'error' in response:
274 # treat as a server error.
282 raise LfsRemoteError(_('LFS server error: %r') % response)
275 code = response.get('error').get('code', 500)
276
277 ptrmap = {p.oid(): p for p in pointers}
278 p = ptrmap.get(response['oid'], None)
279 if p:
280 filename = getattr(p, 'filename', 'unknown')
281 errors = {
282 404: 'The object does not exist',
283 410: 'The object was removed by the owner',
284 422: 'Validation error',
285 500: 'Internal server error',
286 }
287 msg = errors.get(code, 'status code %d' % code)
288 raise LfsRemoteError(_('LFS server error for "%s": %s')
289 % (filename, msg))
290 else:
291 raise LfsRemoteError(
292 _('LFS server error. Unsolicited response for oid %s')
293 % response['oid'])
283
294
284 def _extractobjects(self, response, pointers, action):
295 def _extractobjects(self, response, pointers, action):
285 """extract objects from response of the batch API
296 """extract objects from response of the batch API
@@ -449,7 +449,7 b' TODO: give the proper error indication f'
449 Content-Type: text/plain; charset=utf-8 (git-server !)
449 Content-Type: text/plain; charset=utf-8 (git-server !)
450 Date: $HTTP_DATE$ (git-server !)
450 Date: $HTTP_DATE$ (git-server !)
451 abort: corrupt remote lfs object: d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (git-server !)
451 abort: corrupt remote lfs object: d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (git-server !)
452 abort: LFS server error. Remote object for "c" not found: *! (glob) (hg-server !)
452 abort: LFS server error for "c": Validation error! (hg-server !)
453 [255]
453 [255]
454
454
455 The corrupted blob is not added to the usercache or local store
455 The corrupted blob is not added to the usercache or local store
@@ -807,7 +807,7 b' Check error message when the remote miss'
807 ]
807 ]
808 "transfer": "basic" (hg-server !)
808 "transfer": "basic" (hg-server !)
809 }
809 }
810 abort: LFS server error. Remote object for "b" not found:(.*)! (re)
810 abort: LFS server error for "b": The object does not exist!
811 [255]
811 [255]
812
812
813 Check error message when object does not exist:
813 Check error message when object does not exist:
@@ -918,7 +918,7 b' Check error message when object does not'
918 ]
918 ]
919 "transfer": "basic" (hg-server !)
919 "transfer": "basic" (hg-server !)
920 }
920 }
921 abort: LFS server error. Remote object for "a" not found:(.*)! (re)
921 abort: LFS server error for "a": The object does not exist!
922 [255]
922 [255]
923
923
924 $ $PYTHON $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
924 $ $PYTHON $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
General Comments 0
You need to be logged in to leave comments. Login now