##// END OF EJS Templates
errors: make formatparse() an instance method on ParseError...
Martin von Zweigbergk -
r46496:98399dd1 default
parent child Browse files
Show More
@@ -62,7 +62,6 b' from . import ('
62 62 extensions,
63 63 node,
64 64 pycompat,
65 scmutil,
66 65 util,
67 66 )
68 67
@@ -508,7 +507,7 b' class chgcmdserver(commandserver.server)'
508 507 try:
509 508 self.ui, lui = _loadnewui(self.ui, args, self.cdebug)
510 509 except error.ParseError as inst:
511 scmutil.formatparse(self.ui.warn, inst)
510 self.ui.warn(inst.format())
512 511 self.ui.flush()
513 512 self.cresult.write(b'exit 255')
514 513 return
@@ -261,7 +261,7 b' def dispatch(req):'
261 261 ferr.write(_(b"(%s)\n") % inst.hint)
262 262 return -1
263 263 except error.ParseError as inst:
264 scmutil.formatparse(ferr.write, inst)
264 ferr.write(inst.format())
265 265 return -1
266 266
267 267 msg = _formatargs(req.args)
@@ -469,7 +469,7 b' def _callcatch(ui, func):'
469 469 ui.warn(_(b"hg: %s\n") % inst.message)
470 470 ui.warn(_(b"(use 'hg help -v' for a list of global options)\n"))
471 471 except error.ParseError as inst:
472 scmutil.formatparse(ui.warn, inst)
472 ui.warn(inst.format())
473 473 return -1
474 474 except error.UnknownCommand as inst:
475 475 nocmdmsg = _(b"hg: unknown command '%s'\n") % inst.command
@@ -267,6 +267,20 b' class ParseError(Hint, Exception):'
267 267
268 268 __bytes__ = _tobytes
269 269
270 def format(self):
271 from .i18n import _
272
273 if self.location is not None:
274 message = _(b"hg: parse error at %s: %s\n") % (
275 pycompat.bytestr(self.location),
276 self.message,
277 )
278 else:
279 message = _(b"hg: parse error: %s\n") % self.message
280 if self.hint:
281 message += _(b"(%s)\n") % self.hint
282 return message
283
270 284
271 285 class PatchError(Exception):
272 286 __bytes__ = _tobytes
@@ -142,18 +142,6 b' def nochangesfound(ui, repo, excluded=No'
142 142 ui.status(_(b"no changes found\n"))
143 143
144 144
145 def formatparse(write, inst):
146 if inst.location is not None:
147 write(
148 _(b"hg: parse error at %s: %s\n")
149 % (pycompat.bytestr(inst.location), inst.message)
150 )
151 else:
152 write(_(b"hg: parse error: %s\n") % inst.message)
153 if inst.hint:
154 write(_(b"(%s)\n") % inst.hint)
155
156
157 145 def callcatch(ui, func):
158 146 """call func() with global exception handling
159 147
General Comments 0
You need to be logged in to leave comments. Login now