diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2020-12-22 20:07:39 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2020-12-22 20:07:39 -0500 |
commit | 16963a8e1af2babe0b0abc0ca044de8877e03617 (patch) | |
tree | d4b6c9f53143b69ae51be10dc8609a43a4f58d1a /klippy/configfile.py | |
parent | ca8e6ad89beb7d372c80a2d40b64a3bd48b21ac9 (diff) | |
download | kutter-16963a8e1af2babe0b0abc0ca044de8877e03617.tar.gz kutter-16963a8e1af2babe0b0abc0ca044de8877e03617.tar.xz kutter-16963a8e1af2babe0b0abc0ca044de8877e03617.zip |
configfile: Improve error message when a required option is missing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/configfile.py')
-rw-r--r-- | klippy/configfile.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/klippy/configfile.py b/klippy/configfile.py index f21c4779..ffabf946 100644 --- a/klippy/configfile.py +++ b/klippy/configfile.py @@ -23,9 +23,11 @@ class ConfigWrapper: return self.section def _get_wrapper(self, parser, option, default, minval=None, maxval=None, above=None, below=None, note_valid=True): - if (default is not sentinel - and not self.fileconfig.has_option(self.section, option)): - return default + if not self.fileconfig.has_option(self.section, option): + if default is not sentinel: + return default + raise error("Option '%s' in section '%s' must be specified" + % (option, self.section)) if note_valid: self.access_tracking[(self.section.lower(), option.lower())] = 1 try: |