diff options
author | MS <ms@taler.net> | 2020-11-02 16:35:06 +0100 |
---|---|---|
committer | MS <ms@taler.net> | 2020-11-02 16:35:06 +0100 |
commit | 5d2eb1dac4811639eaaff536fc9813424b13ab64 (patch) | |
tree | 4208699959da0ed331801efe553415d03175565f | |
parent | b9bed3ce5f64d3974d068b7c3f6aaca559495fcd (diff) | |
download | taler-util-5d2eb1dac4811639eaaff536fc9813424b13ab64.tar.gz taler-util-5d2eb1dac4811639eaaff536fc9813424b13ab64.tar.bz2 taler-util-5d2eb1dac4811639eaaff536fc9813424b13ab64.zip |
TalerConfig.
Avoid throwing stack traces when a value is
missing from configuration.
-rw-r--r-- | taler/util/talerconfig.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/taler/util/talerconfig.py b/taler/util/talerconfig.py index 8427f33..699de84 100644 --- a/taler/util/talerconfig.py +++ b/taler/util/talerconfig.py @@ -1,4 +1,3 @@ -# This file is part of TALER # (C) 2016, 2019 Taler Systems SA # # This library is free software; you can redistribute it and/or @@ -111,7 +110,6 @@ def expand(var: str, getter: Callable[[str], str]) -> str: return result + var[pos:] - ## # A configuration entry. class Entry: @@ -170,10 +168,10 @@ class Entry: # @return the value, or the given @a default, if not found. def value_string(self, default=None, required=False, warn=False) -> str: if required and self.value is None: - raise ConfigurationError( - "Missing required option '%s' in section '%s'" - % (self.option.upper(), self.section.upper()) - ) + print("Missing required option '%s' in section '%s'" + % (self.option.upper(), self.section.upper())) + sys.exit(1) + if self.value is None: if warn: if default is not None: @@ -209,10 +207,11 @@ class Entry: try: return int(value) except ValueError: - raise ConfigurationError( + print( "Expected number for option '%s' in section '%s'" % (self.option.upper(), self.section.upper()) ) + sys.exit(1) ## # Fetch value to substitute to expansion variables. |