Browse Source

Add better MT debugging messages, and provide default value if none given.

Bentley James Oakes 7 years ago
parent
commit
ab5182121e
3 changed files with 21 additions and 10 deletions
  1. 14 8
      asworker.js
  2. 1 1
      mt/mtworker.py
  3. 6 1
      mt/ptcal/compiler.py

+ 14 - 8
asworker.js

@@ -139,14 +139,20 @@ module.exports = {
 			}
 
 
-
-			_do.chain(actions)(
-					function() 
-					{
-						__postMessage({'statusCode':200, 'respIndex':resp});
-					},
-					function(err) 	{__postInternalErrorMsg(resp,err);}
-			);
+            _do.chain(actions)(
+                function () {
+                    __postMessage({'statusCode': 200, 'respIndex': resp});
+                },
+                function (err) {
+                    if (err.includes("ECONNREFUSED")) {
+                        let msg = "could not connect to model transformation worker!\n" +
+                            "please ensure the worker is running!";
+                        __postInternalErrorMsg(resp, msg);
+                    } else {
+                        __postInternalErrorMsg(resp, err);
+                    }
+                }
+            );
 		},
 
 		

+ 1 - 1
mt/mtworker.py

@@ -187,7 +187,7 @@ class mtworkerThread(threading.Thread) :
 				self._postMessage(
 						msg['resp'],
 						{'statusCode':500,
-  						 'reason':str(e)})
+  						 'reason':"Error in model transformation worker: " + str(e)})
 				
 		elif msg['method'] == 'PUT' and re.match('/query.transform',msg['uri']):
 			try :

+ 6 - 1
mt/ptcal/compiler.py

@@ -521,7 +521,12 @@ class ModelAndRuleCompiler :
             fulltype = mm+'/'+type
             self._mmTypeData[fulltype] = {}
             for attr in mmData['types'][type] :
-                self._mmTypeData[fulltype][attr['name']] = attr['default']                
+
+                # if there is no default, provide an empty string
+                try:
+                    self._mmTypeData[fulltype][attr['name']] = attr['default']
+                except KeyError:
+                    self._mmTypeData[fulltype][attr['name']] = ""
 
 
     '''