diff --git a/worlds/Files.py b/worlds/Files.py index 336a3090..dbeb54cf 100644 --- a/worlds/Files.py +++ b/worlds/Files.py @@ -41,6 +41,13 @@ class AutoPatchRegister(abc.ABCMeta): current_patch_version: int = 5 +class InvalidDataError(Exception): + """ + Since games can override `read_contents` in APContainer, + this is to report problems in that process. + """ + + class APContainer: """A zipfile containing at least archipelago.json""" version: int = current_patch_version @@ -89,7 +96,15 @@ class APContainer: with zipfile.ZipFile(zip_file, "r") as zf: if file: self.path = zf.filename - self.read_contents(zf) + try: + self.read_contents(zf) + except Exception as e: + message = "" + if len(e.args): + arg0 = e.args[0] + if isinstance(e.args[0], str): + message = f"{arg0} - " + raise InvalidDataError(f"{message}This might be the incorrect world version for this file") from e def read_contents(self, opened_zipfile: zipfile.ZipFile) -> None: with opened_zipfile.open("archipelago.json", "r") as f: