Generate better error messages
This commit is contained in:
@@ -136,7 +136,12 @@ class Gameplay():
|
|||||||
|
|
||||||
def _handle_actions(self):
|
def _handle_actions(self):
|
||||||
for func, args in self.actions[self.world.current_time]:
|
for func, args in self.actions[self.world.current_time]:
|
||||||
|
try:
|
||||||
func(*args)
|
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]
|
del self.actions[self.world.current_time]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
11
aoe/world.py
11
aoe/world.py
@@ -528,7 +528,18 @@ class World():
|
|||||||
|
|
||||||
def _handle_events(self):
|
def _handle_events(self):
|
||||||
for func, args in self.events[self.current_time]:
|
for func, args in self.events[self.current_time]:
|
||||||
|
try:
|
||||||
func(*args)
|
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]
|
del self.events[self.current_time]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user