From patchwork Mon Apr 19 20:04:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D10466: errors: introduce a class for remote errors From: phabricator X-Patchwork-Id: 48783 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 19 Apr 2021 20:04:56 +0000 martinvonz created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Having an exception for remote errors makes it much easier to exit with the right detailed exit code. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10466 AFFECTED FILES mercurial/error.py mercurial/scmutil.py CHANGE DETAILS To: martinvonz, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -222,7 +222,7 @@ detailed_exit_code = 30 elif isinstance(inst, error.HookAbort): detailed_exit_code = 40 - elif isinstance(inst, error.OutOfBandError): + elif isinstance(inst, error.RemoteError): detailed_exit_code = 100 elif isinstance(inst, error.SecurityError): detailed_exit_code = 150 diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -304,7 +304,13 @@ Abort.__init__(self, _(b'response expected')) -class OutOfBandError(Abort): +class RemoteError(Abort): + """Exception raised when interacting with a remote repo fails""" + + __bytes__ = _tobytes + + +class OutOfBandError(RemoteError): """Exception raised when a remote repo reports failure""" def __init__(self, *messages, hint=None):