diff options
author | Michaël Ball <git@michaelball.name> | 2021-12-21 19:43:28 +0000 |
---|---|---|
committer | Michaël Ball <git@michaelball.name> | 2021-12-21 19:43:28 +0000 |
commit | a8699199713c51df196e6e2d0e803d983767664f (patch) | |
tree | ddec07355fc0fec75cb76ed7c88dae002fbb750b | |
parent | cf4018d97cd7c46ffa171e2f6b84e6a50e27a772 (diff) |
Better error handling
-rw-r--r-- | main.py | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -13,14 +13,14 @@ def get_location(args): config = ConfigParser() config_location = xdg_config_home().joinpath("auto-dark-mode", "config") - with open(config_location) as stream: - config.read_string("[auto-dark-mode]\n" + stream.read()) - config.read(config_location) - try: + with open(config_location) as stream: + config.read_string("[auto-dark-mode]\n" + stream.read()) + config.read(config_location) + latitude = config.getfloat("auto-dark-mode", "latitude") longitude = config.getfloat("auto-dark-mode", "longitude") - except NoOptionError: + except (FileNotFoundError, NoOptionError): sys.exit( f"Please supply latitude and longitude with the --latitude and --longitude flags, or set them in {config_location}" ) |