mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Core: clarify error message when reading an APContainer
(#2887)
This commit is contained in:
@@ -41,6 +41,13 @@ class AutoPatchRegister(abc.ABCMeta):
|
|||||||
current_patch_version: int = 5
|
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:
|
class APContainer:
|
||||||
"""A zipfile containing at least archipelago.json"""
|
"""A zipfile containing at least archipelago.json"""
|
||||||
version: int = current_patch_version
|
version: int = current_patch_version
|
||||||
@@ -89,7 +96,15 @@ class APContainer:
|
|||||||
with zipfile.ZipFile(zip_file, "r") as zf:
|
with zipfile.ZipFile(zip_file, "r") as zf:
|
||||||
if file:
|
if file:
|
||||||
self.path = zf.filename
|
self.path = zf.filename
|
||||||
|
try:
|
||||||
self.read_contents(zf)
|
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:
|
def read_contents(self, opened_zipfile: zipfile.ZipFile) -> None:
|
||||||
with opened_zipfile.open("archipelago.json", "r") as f:
|
with opened_zipfile.open("archipelago.json", "r") as f:
|
||||||
|
Reference in New Issue
Block a user