Mercurial > public > mercurial-scm > hg-stable
diff mercurial/error.py @ 46975:14ddb1dca2c0
errors: make OutOfBandError extend Abort
I'm about to create a new `RemoteError` exception and make
`OutOfBandError` extend it. This patch prepares for that.
Differential Revision: https://phab.mercurial-scm.org/D10465
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 19 Apr 2021 10:49:15 -0700 |
parents | 8b6e36e4b553 |
children | f9482db16cef |
line wrap: on
line diff
--- a/mercurial/error.py Mon Apr 05 12:22:25 2021 +0200 +++ b/mercurial/error.py Mon Apr 19 10:49:15 2021 -0700 @@ -304,10 +304,19 @@ Abort.__init__(self, _(b'response expected')) -class OutOfBandError(Hint, Exception): +class OutOfBandError(Abort): """Exception raised when a remote repo reports failure""" - __bytes__ = _tobytes + def __init__(self, *messages, **kwargs): + from .i18n import _ + + if messages: + message = _(b"remote error:\n%s") % b''.join(messages) + # Abort.format() adds a trailing newline + message = message.rstrip(b'\n') + else: + message = _(b"remote error") + super(OutOfBandError, self).__init__(message, **kwargs) class ParseError(Abort):