Replace LOG messages with proper exception handling, ensure that a check which raises an exception causes a rule to fail, as well as being reported in the server log

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@13238 282e977c-c81d-0410-88c4-b93c2d0d6712
master
cavesomething 2010-05-15 21:42:10 +00:00
parent 9ccec00729
commit c011312943
1 changed files with 9 additions and 5 deletions

View File

@ -267,13 +267,15 @@ class Dialog:
speaker = self.__speaker
verdict = True
for condition in rule.getPreconditions():
Crossfire.Log(Crossfire.LogDebug, "CFDialog: Trying to test %s." % condition)
action = condition[0]
args = condition[1:]
path = os.path.join(Crossfire.DataDirectory(), Crossfire.MapDirectory(), 'python/dialog/pre/', action + '.py')
if os.path.isfile(path):
Crossfire.Log(Crossfire.LogDebug, "CFDialog: performing test %s." % action)
exec(open(path).read())
try:
exec(open(path).read())
except:
Crossfire.Log(Crossfire.LogError, "CFDialog: Failed to evaluate condition %s." % condition)
verdict = False
if verdict == False:
return 0
else:
@ -298,8 +300,10 @@ class Dialog:
args = condition[1:]
path = os.path.join(Crossfire.DataDirectory(), Crossfire.MapDirectory(), 'python/dialog/post/', action + '.py')
if os.path.isfile(path):
Crossfire.Log(Crossfire.LogDebug, "CFDialog: implementing action %s." % action)
exec(open(path).read())
try:
exec(open(path).read())
except:
Crossfire.Log(Crossfire.LogError, "CFDialog: Failed to set post-condition %s." % condition)
else:
Crossfire.Log(Crossfire.LogError, "CFDialog: Post Block called with unknown action %s." % action)