Mercurial > hg
comparison hgext/lfs/blobstore.py @ 40659:8863f08c1630
lfs: provide more Batch API error info via a hint in the raised exception
A coworker had a typo in `lfs.url`, forgot it was even set because usually the
blob server is inferred, and then got a 404. It would have been easier to debug
with the failing URL printed.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 15 Nov 2018 17:55:01 -0500 |
parents | b63dee7bd0d9 |
children | 9f78d10742af |
comparison
equal
deleted
inserted
replaced
40658:4ec8bee15930 | 40659:8863f08c1630 |
---|---|
261 objects = [{'oid': p.oid(), 'size': p.size()} for p in pointers] | 261 objects = [{'oid': p.oid(), 'size': p.size()} for p in pointers] |
262 requestdata = json.dumps({ | 262 requestdata = json.dumps({ |
263 'objects': objects, | 263 'objects': objects, |
264 'operation': action, | 264 'operation': action, |
265 }) | 265 }) |
266 batchreq = util.urlreq.request('%s/objects/batch' % self.baseurl, | 266 url = '%s/objects/batch' % self.baseurl |
267 data=requestdata) | 267 batchreq = util.urlreq.request(url, data=requestdata) |
268 batchreq.add_header('Accept', 'application/vnd.git-lfs+json') | 268 batchreq.add_header('Accept', 'application/vnd.git-lfs+json') |
269 batchreq.add_header('Content-Type', 'application/vnd.git-lfs+json') | 269 batchreq.add_header('Content-Type', 'application/vnd.git-lfs+json') |
270 try: | 270 try: |
271 rsp = self.urlopener.open(batchreq) | 271 rsp = self.urlopener.open(batchreq) |
272 rawjson = rsp.read() | 272 rawjson = rsp.read() |
273 except util.urlerr.httperror as ex: | 273 except util.urlerr.httperror as ex: |
274 raise LfsRemoteError(_('LFS HTTP error: %s (action=%s)') | 274 raise LfsRemoteError(_('LFS HTTP error: %s') % ex, |
275 % (ex, action)) | 275 hint=_('api=%s, action=%s') |
276 % (url, action)) | |
276 try: | 277 try: |
277 response = json.loads(rawjson) | 278 response = json.loads(rawjson) |
278 except ValueError: | 279 except ValueError: |
279 raise LfsRemoteError(_('LFS server returns invalid JSON: %s') | 280 raise LfsRemoteError(_('LFS server returns invalid JSON: %s') |
280 % rawjson) | 281 % rawjson) |