comparison 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
comparison
equal deleted inserted replaced
46974:3c9208702db3 46975:14ddb1dca2c0
302 from .i18n import _ 302 from .i18n import _
303 303
304 Abort.__init__(self, _(b'response expected')) 304 Abort.__init__(self, _(b'response expected'))
305 305
306 306
307 class OutOfBandError(Hint, Exception): 307 class OutOfBandError(Abort):
308 """Exception raised when a remote repo reports failure""" 308 """Exception raised when a remote repo reports failure"""
309 309
310 __bytes__ = _tobytes 310 def __init__(self, *messages, **kwargs):
311 from .i18n import _
312
313 if messages:
314 message = _(b"remote error:\n%s") % b''.join(messages)
315 # Abort.format() adds a trailing newline
316 message = message.rstrip(b'\n')
317 else:
318 message = _(b"remote error")
319 super(OutOfBandError, self).__init__(message, **kwargs)
311 320
312 321
313 class ParseError(Abort): 322 class ParseError(Abort):
314 """Raised when parsing config files and {rev,file}sets (msg[, pos])""" 323 """Raised when parsing config files and {rev,file}sets (msg[, pos])"""
315 324