Patchwork [2,of,4] error: make ParseError inherrit from HintException

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 23, 2015, 5:58 p.m.
Message ID <b87c3846c54f22d270d7.1450893531@waste.org>
Download mbox | patch
Permalink /patch/12302/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

timeless@mozdev.org - Dec. 23, 2015, 5:58 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1450892372 0
#      Wed Dec 23 17:39:32 2015 +0000
# Node ID b87c3846c54f22d270d71c42d8b80d21b51a927e
# Parent  96379fd1a2478dc4702844e5518396fee28d7414
error: make ParseError inherrit from HintException

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -107,6 +107,8 @@ 
         return -1
     except error.ParseError as inst:
         _formatparse(ferr.write, inst)
+        if inst.hint:
+            ferr.write(_("(%s)\n") % inst.hint)
         return -1
 
     msg = ' '.join(' ' in a and repr(a) or a for a in req.args)
@@ -202,6 +204,8 @@ 
                 (inst.args[0], " ".join(inst.args[1])))
     except error.ParseError as inst:
         _formatparse(ui.warn, inst)
+        if inst.hint:
+            ui.warn(_("(%s)\n") % inst.hint)
         return -1
     except error.LockHeld as inst:
         if inst.errno == errno.ETIMEDOUT:
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -81,7 +81,7 @@ 
 class OutOfBandError(HintException):
     """Exception raised when a remote repo reports failure"""
 
-class ParseError(Exception):
+class ParseError(HintException):
     """Raised when parsing config files and {rev,file}sets (msg[, pos])"""
 
 class UnknownIdentifier(ParseError):