Comments
Patch
@@ -685,9 +685,7 @@
# We did not change it to minimise code change.
# This need to be moved to something proper.
# Feel free to do it.
- procutil.stderr.write(b"abort: %s\n" % exc.message)
- if exc.hint is not None:
- procutil.stderr.write(b"(%s)\n" % exc.hint)
+ procutil.stderr.write(exc.format())
procutil.stderr.flush()
return wireprototypes.pushres(
0, output.getvalue() if output else b''
@@ -230,9 +230,7 @@
detailed_exit_code = 30
elif isinstance(inst, error.CanceledError):
detailed_exit_code = 250
- ui.error(_(b"abort: %s\n") % inst.message)
- if inst.hint:
- ui.error(_(b"(%s)\n") % inst.hint)
+ ui.error(inst.format())
except error.WorkerError as inst:
# Don't print a message -- the worker already should have
return inst.status_code
@@ -182,6 +182,14 @@
# may raise another exception.
return pycompat.sysstr(self.__bytes__())
+ def format(self):
+ from .i18n import _
+
+ message = _(b"abort: %s\n") % self.message
+ if self.hint:
+ message += _(b"(%s)\n") % self.hint
+ return message
+
class InputError(Abort):
"""Indicates that the user made an error in their input.
@@ -256,9 +256,7 @@
if req.fmsg:
req.ui.fmsg = req.fmsg
except error.Abort as inst:
- ferr.write(_(b"abort: %s\n") % inst.message)
- if inst.hint:
- ferr.write(_(b"(%s)\n") % inst.hint)
+ ferr.write(inst.format())
return -1
except error.ParseError as inst:
ferr.write(inst.format())
@@ -512,9 +512,7 @@
self.cresult.write(b'exit 255')
return
except error.Abort as inst:
- self.ui.error(_(b"abort: %s\n") % inst.message)
- if inst.hint:
- self.ui.error(_(b"(%s)\n") % inst.hint)
+ self.ui.error(inst.format())
self.ui.flush()
self.cresult.write(b'exit 255')
return