Core: trace error to player, if possible. (#2023)

This commit is contained in:
Fabian Dill 2023-07-25 02:18:39 +02:00 committed by GitHub
parent bb069443a4
commit 6a96f33ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -98,7 +98,17 @@ class AutoLogicRegister(type):
def call_single(multiworld: "MultiWorld", method_name: str, player: int, *args: Any) -> Any:
method = getattr(multiworld.worlds[player], method_name)
return method(*args)
try:
ret = method(*args)
except Exception as e:
message = f"Exception in {method} for player {player}, named {multiworld.player_name[player]}."
if sys.version_info >= (3, 11, 0):
e.add_note(message) # PEP 678
else:
logging.error(message)
raise e
else:
return ret
def call_all(multiworld: "MultiWorld", method_name: str, *args: Any) -> None: