Try to detect unsupported config file encoding

The encoding detection is quite rudimentary, but should detect the
default windows encoding in many cases.
This commit is contained in:
I-Al-Istannen 2022-04-27 21:48:09 +02:00
parent a99ddaa0cc
commit a709280cbf

View File

@ -128,6 +128,8 @@ class Config:
raise ConfigLoadError(path, "That's a directory, not a file") raise ConfigLoadError(path, "That's a directory, not a file")
except PermissionError: except PermissionError:
raise ConfigLoadError(path, "Insufficient permissions") raise ConfigLoadError(path, "Insufficient permissions")
except UnicodeDecodeError:
raise ConfigLoadError(path, "File is not encoded using UTF-8")
def dump(self, path: Optional[Path] = None) -> None: def dump(self, path: Optional[Path] = None) -> None:
""" """