Mercurial > public > mercurial-scm > hg-stable
diff hgext/lfs/blobstore.py @ 40701:9f78d10742af
lfs: improve the hints for common errors in the Batch API
The previous message was too debug-ish and less action oriented than a hint
should be. The remaining errors that aren't handled are more along the lines of
programming errors (not using POST, bad accept type, etc), so I'm not bothering
with that.
The friendly errors purposely use `self.baseurl` instead of the full Batch API
endpoint because I'd expect some copy/paste/modify on the part of the user here,
and it would be more confusing if '/objects/batch' magically appeared, but
shouldn't be used in the config setting. It still seems like the right thing
for debugging in the catchall case.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 15 Nov 2018 17:58:59 -0500 |
parents | 8863f08c1630 |
children | 380f5131ee7b |
line wrap: on
line diff
--- a/hgext/lfs/blobstore.py Thu Nov 15 17:55:01 2018 -0500 +++ b/hgext/lfs/blobstore.py Thu Nov 15 17:58:59 2018 -0500 @@ -271,9 +271,14 @@ rsp = self.urlopener.open(batchreq) rawjson = rsp.read() except util.urlerr.httperror as ex: - raise LfsRemoteError(_('LFS HTTP error: %s') % ex, - hint=_('api=%s, action=%s') - % (url, action)) + hints = { + 400: _('check that lfs serving is enabled on %s and "%s" is ' + 'supported') % (self.baseurl, action), + 404: _('the "lfs.url" config may be used to override %s') + % self.baseurl, + } + hint = hints.get(ex.code, _('api=%s, action=%s') % (url, action)) + raise LfsRemoteError(_('LFS HTTP error: %s') % ex, hint=hint) try: response = json.loads(rawjson) except ValueError: