From c01131294335697c37053feee63a50a405984e96 Mon Sep 17 00:00:00 2001 From: cavesomething Date: Sat, 15 May 2010 21:42:10 +0000 Subject: [PATCH] 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 --- python/CFDialog.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/python/CFDialog.py b/python/CFDialog.py index c5ac859a9..66e8006e4 100644 --- a/python/CFDialog.py +++ b/python/CFDialog.py @@ -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)