##// 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 extensions,
62 extensions,
63 node,
63 node,
64 pycompat,
64 pycompat,
65 scmutil,
66 util,
65 util,
67 )
66 )
68
67
@@ -508,7 +507,7 b' class chgcmdserver(commandserver.server)'
508 try:
507 try:
509 self.ui, lui = _loadnewui(self.ui, args, self.cdebug)
508 self.ui, lui = _loadnewui(self.ui, args, self.cdebug)
510 except error.ParseError as inst:
509 except error.ParseError as inst:
511 scmutil.formatparse(self.ui.warn, inst)
510 self.ui.warn(inst.format())
512 self.ui.flush()
511 self.ui.flush()
513 self.cresult.write(b'exit 255')
512 self.cresult.write(b'exit 255')
514 return
513 return
@@ -261,7 +261,7 b' def dispatch(req):'
261 ferr.write(_(b"(%s)\n") % inst.hint)
261 ferr.write(_(b"(%s)\n") % inst.hint)
262 return -1
262 return -1
263 except error.ParseError as inst:
263 except error.ParseError as inst:
264 scmutil.formatparse(ferr.write, inst)
264 ferr.write(inst.format())
265 return -1
265 return -1
266
266
267 msg = _formatargs(req.args)
267 msg = _formatargs(req.args)
@@ -469,7 +469,7 b' def _callcatch(ui, func):'
469 ui.warn(_(b"hg: %s\n") % inst.message)
469 ui.warn(_(b"hg: %s\n") % inst.message)
470 ui.warn(_(b"(use 'hg help -v' for a list of global options)\n"))
470 ui.warn(_(b"(use 'hg help -v' for a list of global options)\n"))
471 except error.ParseError as inst:
471 except error.ParseError as inst:
472 scmutil.formatparse(ui.warn, inst)
472 ui.warn(inst.format())
473 return -1
473 return -1
474 except error.UnknownCommand as inst:
474 except error.UnknownCommand as inst:
475 nocmdmsg = _(b"hg: unknown command '%s'\n") % inst.command
475 nocmdmsg = _(b"hg: unknown command '%s'\n") % inst.command
@@ -267,6 +267,20 b' class ParseError(Hint, Exception):'
267
267
268 __bytes__ = _tobytes
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 class PatchError(Exception):
285 class PatchError(Exception):
272 __bytes__ = _tobytes
286 __bytes__ = _tobytes
@@ -142,18 +142,6 b' def nochangesfound(ui, repo, excluded=No'
142 ui.status(_(b"no changes found\n"))
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 def callcatch(ui, func):
145 def callcatch(ui, func):
158 """call func() with global exception handling
146 """call func() with global exception handling
159
147
General Comments 0
You need to be logged in to leave comments. Login now