mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 01:44:08 +00:00
add ScriptReturnException
This commit is contained in:
parent
cb13076423
commit
8095f9735f
@ -1,6 +1,7 @@
|
||||
package org.bdware.sc.boundry;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import groovy.util.ScriptException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bdware.sc.ContractProcess;
|
||||
@ -328,7 +329,10 @@ public class JavaScriptEntry {
|
||||
return bo.toString();
|
||||
}
|
||||
}
|
||||
|
||||
//YancloudUtil.exceptionReturn({"msg":"missing arguments repoId ","code":1});
|
||||
public static void exceptionReturn(Object obj) throws ScriptReturnException {
|
||||
throw new ScriptReturnException(JSONTool.convertMirrorToJson(obj));
|
||||
}
|
||||
/**
|
||||
* publish an event with semantic AT_LEAST_ONCE
|
||||
*
|
||||
|
@ -0,0 +1,21 @@
|
||||
package org.bdware.sc.boundry;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class ScriptReturnException extends IllegalStateException {
|
||||
// public String message1;
|
||||
// public int code;
|
||||
public JsonObject message;
|
||||
public ScriptReturnException(JsonElement jsonElement) {
|
||||
message=jsonElement.getAsJsonObject();
|
||||
// message=jo.get("msg").getAsString();
|
||||
// code=jo.get("code").getAsInt();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String getMessage() {
|
||||
// return this.message1;
|
||||
//
|
||||
// }
|
||||
}
|
@ -18,6 +18,7 @@ import org.bdware.sc.bean.ContractRequest;
|
||||
import org.bdware.sc.bean.ProjectConfig;
|
||||
import org.bdware.sc.boundry.JavaScriptEntry;
|
||||
import org.bdware.sc.boundry.Resources;
|
||||
import org.bdware.sc.boundry.ScriptReturnException;
|
||||
import org.bdware.sc.boundry.utils.UtilRegistry;
|
||||
import org.bdware.sc.encrypt.HardwareInfo;
|
||||
import org.bdware.sc.encrypt.HardwareInfo.OSType;
|
||||
@ -550,7 +551,13 @@ public class DesktopEngine extends JSEngine {
|
||||
new JsonPrimitive("Action " + input.getAction() + " is not exported!"));
|
||||
}
|
||||
|
||||
} catch (ScriptException e) {
|
||||
}catch (ScriptReturnException e){
|
||||
e.printStackTrace();
|
||||
return new ContractResult(
|
||||
Status.Exception,
|
||||
e.message);
|
||||
}
|
||||
catch (ScriptException e) {
|
||||
Throwable cause = e.getCause();
|
||||
e.printStackTrace();
|
||||
return new ContractResult(
|
||||
|
Loading…
Reference in New Issue
Block a user