Catch configparser exceptions on start

This commit is contained in:
Florian Bruhin 2014-04-25 13:55:26 +02:00
parent 46cf62ab34
commit c9a25d6309
2 changed files with 11 additions and 9 deletions

3
TODO
View File

@ -6,9 +6,6 @@ Weird font rendering
https://bugreports.qt-project.org/browse/QTBUG-20973
https://bugreports.qt-project.org/browse/QTBUG-21036
Changing completion models is awfully slow
new keybinding (not in config) crashes exception handler
Also, what about unknown settings, unknown values, wrong interpolations,
etc.?
values written to config are unordered
values starting with ; need to be escaped

View File

@ -108,12 +108,17 @@ class QuteBrowser(QApplication):
confdir = self._args.confdir
try:
config.init(confdir)
except config.ValidationError as e:
msgbox = QMessageBox(
QMessageBox.Critical,
"Error while reading config!",
"Error while reading config:\n\n{} -> {}:\n{}".format(
e.section, e.option, e))
except (config.ValidationError,
configparser.InterpolationError,
configparser.DuplicateSectionError,
configparser.DuplicateOptionError,
configparser.ParsingError) as e:
errstr = "Error while reading config:"
if hasattr(e, 'section') and hasattr(e, 'option'):
errstr += "\n\n{} -> {}:".format(e.section, e.option)
errstr += "\n{}".format(e)
msgbox = QMessageBox(QMessageBox.Critical,
"Error while reading config!", errstr)
msgbox.exec_()
# We didn't really initialize much so far, so we just quit hard.
sys.exit(1)