You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2012/03/13 14:33:55 UTC

svn commit: r1300117 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/ScriptEngine.java

Author: jacopoc
Date: Tue Mar 13 13:33:55 2012
New Revision: 1300117

URL: http://svn.apache.org/viewvc?rev=1300117&view=rev
Log:
If a ScriptException is thrown while running a script that implements a service then a result map with the error message is automatically returned by the engine: this default error handling mechanism is similar to the one provided by Minilang and allows to delegate to the engine most of the most common error handling logic.

Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/ScriptEngine.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/ScriptEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/ScriptEngine.java?rev=1300117&r1=1300116&r2=1300117&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/ScriptEngine.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/ScriptEngine.java Tue Mar 13 13:33:55 2012
@@ -26,12 +26,14 @@ import java.util.Map;
 import java.util.Set;
 
 import javax.script.ScriptContext;
+import javax.script.ScriptException;
 
 import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Assert;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.ScriptUtil;
+import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.ModelService;
@@ -92,6 +94,8 @@ public final class ScriptEngine extends 
             Map<String, Object> result = ServiceUtil.returnSuccess();
             result.putAll(modelService.makeValid(scriptContext.getBindings(ScriptContext.ENGINE_SCOPE), "OUT"));
             return result;
+        } catch (ScriptException se) {
+            return ServiceUtil.returnError(se.getMessage());
         } catch (Exception e) {
             Debug.logWarning(e, "Error invoking service " + modelService.name + ": ", module);
             throw new GenericServiceException(e);