Better display of Python exceptions from Py_Eval
authorEdouard Tisserant
Wed, 24 Apr 2013 17:21:20 +0900
changeset 1052 fa7c5034c1d2
parent 1051 847d68c3e7ff
child 1053 b0ac30ba7eaf
Better display of Python exceptions from Py_Eval
runtime/PLCObject.py
--- a/runtime/PLCObject.py	Wed Apr 24 15:44:46 2013 +0900
+++ b/runtime/PLCObject.py	Wed Apr 24 17:21:20 2013 +0900
@@ -246,7 +246,7 @@
         for method in self.python_runtime_vars.get("_runtime_%s"%methodname, []):
             res,exp = self.evaluator(method)
             if exp is not None: 
-                self.LogMessage(0,traceback.format_exception(*exp))
+                self.LogMessage(0,'\n'.join(traceback.format_exception(*exp)))
 
     def PythonRuntimeInit(self):
         MethodNames = ["init", "start", "stop", "cleanup"]
@@ -309,7 +309,9 @@
                     compile_cache[FBID]=(cmd,AST)
                 result,exp = self.evaluator(eval,cmd,self.python_runtime_vars)
                 if exp is not None: 
-                    raise(exp[1])
+                    res = "#EXCEPTION : "+str(exp[1])
+                    self.LogMessage(1,('PyEval@0x%x(Code="%s") Exception "%s"')%(FBID,cmd,
+                        '\n'.join(traceback.format_exception(*exp))))
                 else:
                     res=str(result)
                 self.python_runtime_vars["FBID"]=None