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