diff --git a/aoe/gameplay.py b/aoe/gameplay.py index 752faca..d5868f3 100644 --- a/aoe/gameplay.py +++ b/aoe/gameplay.py @@ -136,7 +136,12 @@ class Gameplay(): def _handle_actions(self): for func, args in self.actions[self.world.current_time]: - func(*args) + try: + func(*args) + except Exception as e: + raise type(e)( + f'Error in {func.__name__}{args}' + f' at time {self.world.current_time}.') from e del self.actions[self.world.current_time] diff --git a/aoe/world.py b/aoe/world.py index 778690b..4d8c8a5 100644 --- a/aoe/world.py +++ b/aoe/world.py @@ -528,7 +528,18 @@ class World(): def _handle_events(self): for func, args in self.events[self.current_time]: - func(*args) + try: + func(*args) + except Exception as e: + raise type(e)( + f'Error in {func.__name__}{args}' + f' at time {self.current_time}.' + f' Note that the actual gameplay command that caused' + f' the error may not have been issued at' + f' {self.current_time} -- the action may have been' + f' delayed until that time while' + f' waiting in a queue') from e + del self.events[self.current_time]