comparison mercurial/ui.py @ 43909:dbaf9aabfb69

config: catch intended exception when failing to parse config When a new config parser was introduced in fca54469480e (ui: introduce new config parser, 2009-04-23), the reading side would raise a ConfigError which was then caught in the ui code. Then, in 2123aad24d56 (error: add new ParseError for various parsing errors, 2010-06-04), a ParseError was raised instead, but the call site was not updated. Let's start catching that ParseError. We still don't print it in a friendly way, but that's not worse than before. Differential Revision: https://phab.mercurial-scm.org/D7625
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 11 Dec 2019 15:33:07 -0800
parents e63b27fb0595
children c41ed5d4f770
comparison
equal deleted inserted replaced
43908:4b3c8df189bc 43909:dbaf9aabfb69
438 trusted = sections or trust or self._trusted(fp, filename) 438 trusted = sections or trust or self._trusted(fp, filename)
439 439
440 try: 440 try:
441 cfg.read(filename, fp, sections=sections, remap=remap) 441 cfg.read(filename, fp, sections=sections, remap=remap)
442 fp.close() 442 fp.close()
443 except error.ConfigError as inst: 443 except error.ParseError as inst:
444 if trusted: 444 if trusted:
445 raise 445 raise
446 self.warn(_(b"ignored: %s\n") % stringutil.forcebytestr(inst)) 446 self.warn(_(b"ignored: %s\n") % stringutil.forcebytestr(inst))
447 447
448 if self.plain(): 448 if self.plain():