List of usage examples for com.google.gwt.core.client JavaScriptException JavaScriptException
protected JavaScriptException(String message)
From source file:com.ait.toolkit.node.dev.debug.JavaInvoker.java
License:Open Source License
@Override public T call(JavaScriptFunctionArguments args) { try {/* w ww.jav a 2 s . com*/ handler.getLog().debug("Called java invoker for %d params", paramCount); //first is the "this" object handler.getLog().debug("dispId type: " + args.get(1).getClass()); Value<?> thisObj = handler.getValueFromJavaScriptObject(args.get(0)); //second is the dispatch ID int dispId = Integer.valueOf(args.get(1).toString()); handler.getLog().debug("dispId: " + dispId); //the rest are arguments Value<?>[] argList = new Value<?>[args.length() - 2]; for (int i = 0; i < argList.length; i++) { argList[i] = handler.getValueFromJavaScriptObject(args.get(i + 2)); } //create the fiber and go with the message return Fiber.create(new FiberReturningCallback<T>() { @Override @SuppressWarnings("unchecked") public T onCreate(Object param) { //push me on the stack waitingForReturn.push(Fiber.current()); handler.getLog().debug("Sending invoke from client"); //send message channel.sendMessage((InvokeFromClientMessage) param, JavaInvoker.this); handler.getLog().debug("Waiting for response from server"); //wait ReturnMessage returnMessage = Fiber.yield(); handler.getLog().debug("Got response from server"); //handle message if (returnMessage.isException()) { throw new JavaScriptException( handler.getJavaScriptObjectFromValue(returnMessage.getReturnValue())); } else { return (T) handler.getJavaScriptObjectFromValue(returnMessage.getReturnValue()); } } }).<T>run(new InvokeFromClientMessage(dispId, thisObj, argList)); } catch (Exception e) { handler.getLog().error("Error: %s", JavaScriptUtils.appendException(e, new StringBuilder())); Process.get().exit(); //throw new RuntimeException(e); return null; } }
From source file:com.codenvy.ide.ext.java.jdt.text.AbstractDocument.java
License:Open Source License
/** * Logs the given exception by reusing the code in {@link SafeRunner}. * * @param ex//from w w w .j a va 2 s .co m * the exception * @since 3.6 */ private static void fail(final Exception ex) { throw new JavaScriptException(ex); }
From source file:gwt.dojo.core.client.Dojo.java
License:Apache License
private static <T> void doCallback(AsyncCallback<T> callback, String error) { try {/* w ww.j a v a2s . co m*/ callback.onFailure(new JavaScriptException(error)); } catch (Throwable t) { handleUncaughtException(t); } }
From source file:org.eclipse.che.ide.jseditor.client.requirejs.RequireJsLoader.java
License:Open Source License
public void require(final Callback<JavaScriptObject[], Throwable> callback, final String[] requiredScripts, final String[] moduleKeys) { // require with default config final RequirejsConfig defaultConfig = RequirejsConfig.create(); /** Using GWT.getModuleBaseForStaticFiles() blocks CodeMirror to run under Super Dev Mode */ defaultConfig.setBaseUrl(GWT.getModuleBaseURL()); defaultConfig.setWaitSeconds(0);/*from w w w . j av a 2s .com*/ require(new RequirejsCallback() { @Override public void onReady(final JsArray<RequirejsModule> modules) { final JavaScriptObject[] result = new JavaScriptObject[modules.length()]; for (int i = 0; i < modules.length(); i++) { result[i] = modules.get(i); } callback.onSuccess(result); } }, new RequirejsErrorHandler() { @Override public void onError(final RequireError error) { callback.onFailure(new JavaScriptException(error)); } }, defaultConfig, requiredScripts, moduleKeys); }
From source file:org.eclipse.che.plugin.requirejs.ide.RequireJsLoader.java
License:Open Source License
public void require(final Callback<JavaScriptObject[], Throwable> callback, final String[] requiredScripts, final String[] moduleKeys) { // require with default config final RequirejsConfig defaultConfig = RequirejsConfig.create(); /** Using GWT.getModuleBaseForStaticFiles() blocks CodeMirror to run under Super Dev Mode */ defaultConfig.setBaseUrl(GWT.getModuleBaseURL()); defaultConfig.setWaitSeconds(0);/*from www.ja v a 2 s .com*/ require(new RequirejsCallback() { @Override public void onReady(final JsArray<RequirejsModule> modules) { final JavaScriptObject[] result = new JavaScriptObject[modules.length()]; for (int i = 0; i < modules.length(); i++) { result[i] = modules.get(i); } callback.onSuccess(result); } }, new RequirejsErrorHandler() { @Override public void onError(final RequireError error) { callback.onFailure(new JavaScriptException(error)); } }, defaultConfig, requiredScripts, moduleKeys); }
From source file:org.gwtnode.core.GwtNodeBootstrap.java
License:Apache License
@Override public final void onModuleLoad() { //unhandled errors GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override/*from w ww .ja v a 2 s. c om*/ public void onUncaughtException(Throwable e) { GwtNodeBootstrap.this.onUncaughtException(e); } }); Process.get().onUncaughtException(new ErrorEventHandler() { @Override public void onEvent(NodeJsError exception) { JavaScriptException e = new JavaScriptException(exception); if (e.getStackTrace().length == 0) { e.fillInStackTrace(); } onUncaughtException(e); } }); Process.get().nextTick(new ParameterlessEventHandler() { @Override public void onEvent() { try { //grab the arguments JsArrayString nativeArgs = Process.get().argv(); //well, the best I can do right now is find the arguments // after the .js argument //TODO: be smarter than this int jsArgIndex; for (jsArgIndex = 0; jsArgIndex < nativeArgs.length(); jsArgIndex++) { if (nativeArgs.get(jsArgIndex).endsWith(".js")) { break; } } //make the final native string array String[] args; if (jsArgIndex == nativeArgs.length()) { Util.get().log("Unable to find argument ending with .js"); args = new String[0]; } else { args = new String[nativeArgs.length() - jsArgIndex - 1]; for (int i = 0; i < args.length; i++) { args[i] = nativeArgs.get(jsArgIndex + i + 1); } } //call the main method Runner runner = GWT.create(Runner.class); runner.run(GwtNodeBootstrap.this, new Closure<Integer>() { @Override public void call(Integer result) { if (result != null) { Process.get().exit(result); } } }, args); } catch (Throwable e) { onUncaughtException(e); } } }); }
From source file:org.gwtnode.dev.debug.JavaInvoker.java
License:Apache License
@Override public T call(JavaScriptFunctionArguments args) { //first is the "this" object Value<?> thisObj = handler.getValueFromJavaScriptObject(args.get(0)); //second is the dispatch ID int dispId = (Integer) args.get(1); //the rest are arguments Value<?>[] argList = new Value<?>[args.length() - 2]; for (int i = 0; i < argList.length; i++) { argList[i] = handler.getValueFromJavaScriptObject(args.get(i + 2)); }//ww w . j a v a2s. c o m InvokeFromClientMessage message = new InvokeFromClientMessage(dispId, thisObj, argList); channel.sendMessage(message, this); //ok, here's where I want to wait... return Fiber.create(new FiberReturningCallback<T>() { @Override @SuppressWarnings("unchecked") public T onCreate(Object param) { //meh, no param //TODO: do proper setTimeout/nextTick/yield things to check the returnMessage, kthxbai while (returnMessage == null) { //blah blah blah } if (returnMessage.isException()) { throw new JavaScriptException( handler.getJavaScriptObjectFromValue(returnMessage.getReturnValue())); } else { return (T) handler.getJavaScriptObjectFromValue(returnMessage.getReturnValue()); } } }).run(); }
From source file:org.sonar.api.web.gwt.client.webservices.JsonUtils.java
License:Open Source License
public static JSONObject getArray(JSONValue json, int i) { if (json instanceof JSONArray) { return ((JSONArray) json).get(i).isObject(); }//w w w.ja v a 2s . c o m if (json instanceof JSONObject) { return ((JSONObject) json).get(Integer.toString(i)).isObject(); } throw new JavaScriptException("Not implemented"); }
From source file:org.sonar.api.web.gwt.client.webservices.JsonUtils.java
License:Open Source License
public static int getArraySize(JSONValue array) { if (array instanceof JSONArray) { return ((JSONArray) array).size(); }/*from w w w. j a va 2s. c om*/ if (array instanceof JSONObject) { return ((JSONObject) array).size(); } throw new JavaScriptException("Not implemented"); }
From source file:org.sonar.plugins.core.clouds.client.GwtClouds.java
License:Open Source License
private Metric getCurrentColorMetric() { String metricKey = metricsListBox.getValue(metricsListBox.getSelectedIndex()); for (Metric color : COLOR_METRICS) { if (color.getKey().equals(metricKey)) { return color; }// w w w .jav a2s . c o m } throw new JavaScriptException("Unable to find metric " + metricKey); }