mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-02 15:59:26 +01:00
conf: when config loading fails, show an error /before/ quitting
This fixes a regression from 2b346e3c01
.
This commit is contained in:
parent
cc9025a080
commit
7e8ff51646
7
conf.py
7
conf.py
@ -123,13 +123,14 @@ def loadConf(filename, errors_fatal=True, logger=None):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
e = 'Failed to load config from %r: %s: %s' % (filename, type(e).__name__, e)
|
e = 'Failed to load config from %r: %s: %s' % (filename, type(e).__name__, e)
|
||||||
|
|
||||||
if errors_fatal:
|
if logger: # Prefer using the Python logger when available
|
||||||
sys.exit(1)
|
|
||||||
elif logger: # Prefer using the Python logger when available
|
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
else: # Otherwise, fall back to a print() call.
|
else: # Otherwise, fall back to a print() call.
|
||||||
print('ERROR: %s' % e, file=sys.stderr)
|
print('ERROR: %s' % e, file=sys.stderr)
|
||||||
|
|
||||||
|
if errors_fatal:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
return conf
|
return conf
|
||||||
|
Loading…
Reference in New Issue
Block a user