Java 类com.google.gwt.core.client.JavaScriptException 实例源码

项目:dangchat-sdk    文件:PeerConnection.java   
@NotNull
@Override
public Promise<WebRTCSessionDescription> setLocalDescription(@NotNull final WebRTCSessionDescription description) {
    return new Promise<>(new PromiseFunc<WebRTCSessionDescription>() {
        @Override
        public void exec(@NotNull final PromiseResolver<WebRTCSessionDescription> resolver) {
            peerConnection.setLocalDescription(JsSessionDescription.create(description.getType(),
                    description.getSdp()), new JsClosure() {
                @Override
                public void callback() {
                    resolver.result(description);
                }
            }, new JsClosureError() {
                @Override
                public void onError(JavaScriptObject error) {
                    resolver.error(new JavaScriptException(error));
                }
            });
        }
    });
}
项目:dangchat-sdk    文件:PeerConnection.java   
@NotNull
@Override
public Promise<WebRTCSessionDescription> setRemoteDescription(@NotNull final WebRTCSessionDescription description) {
    return new Promise<>(new PromiseFunc<WebRTCSessionDescription>() {
        @Override
        public void exec(@NotNull final PromiseResolver<WebRTCSessionDescription> resolver) {
            peerConnection.setRemoteDescription(JsSessionDescription.create(description.getType(),
                    description.getSdp()), new JsClosure() {
                @Override
                public void callback() {
                    resolver.result(description);
                }
            }, new JsClosureError() {
                @Override
                public void onError(JavaScriptObject error) {
                    resolver.error(new JavaScriptException(error));
                }
            });
        }
    });
}
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
@Override
protected void onUnload() {
    boolean deferUnloading = false;
    try {
        if (!uninitialize()) {
            addPendingUnload();
            deferUnloading = true;
        }
    } catch (JavaScriptException e) {
        GWT.log("Unable to clean up TinyMCE editor.", e);
    } finally {
        if (!deferUnloading) {
            super.onUnload();
        }
    }
}
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
private boolean initialize() {
    try {
        if (!isInitialized() && !isInitializing()) {
            initTinyMce(elementId, options.getJavaScriptObject());
            setInitializing(true); // set this after since the above call is asynchronous. We don't want it to be true and an exception to be thrown

            // Even though this entry was set in the constructor, it could have been unset
            // in the unload function. We ensure that we have a valid reference while this
            // editor is initialized
            activeEditors.put(elementId, this);
            getInitializationTimeoutTimer().schedule(1000); // give TinyMCE 1 second to initialize the editor
            return true;
        }
    } catch (JavaScriptException e) {
        GWT.log("Unable to initialize the TinyMCE editor.", e);
    }
    return false;
}
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
private boolean uninitialize() {
     if (isInitialized()) {
        try {
            unloadTinyMce(elementId);            
        } catch (JavaScriptException e) {
            GWT.log("Unable to uninitialize the TinyMCE editor.", e);
        } finally {
            setInitialized(false);
            setInitializing(false);

            // Clear the entry in activeEditors so that we don't hold the memory if it needs to be cleaned up.
            activeEditors.put(elementId, null);
            activeEditors.remove(elementId);
        }
        return true;
    }                
    return false;        
}
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
public SafeHtml getHTML() {
    SafeHtml result = null;
    if (libraryLoaded && initialized) {
        try {
            String contentHtml = getContentHtml(elementId); // TinyMCE takes care of the sanitization.
            if (contentHtml == null || contentHtml.trim().isEmpty()) {
                return SafeHtmlUtils.fromSafeConstant("");
            }
            // Remove the root block <p></p> that gets added automatically by TinyMCE
            if (contentHtml.startsWith("<p>") && contentHtml.endsWith("</p>")) {
                contentHtml = contentHtml.substring(3, contentHtml.length() - 4);
            }
            result = SafeHtmlUtils.fromTrustedString(contentHtml); 
        } catch (JavaScriptException e) {
            GWT.log("Unable to get the content from the TinyMCE editor.", e);
        }
    } else {
        String text = super.getText();
        if (text == null || text.trim().isEmpty()) {
            return SafeHtmlUtils.fromSafeConstant("");
        } else {
            return SafeHtmlUtils.fromString(text);
        }
    }
    return result;        
}
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
public String getText()
{
    String result = "";
    if (libraryLoaded && initialized) {
        try {
            String contentText = getContentText(elementId);
            if (contentText == null) {
                contentText = "";
            }
            result = SafeHtmlUtils.fromString(contentText).asString(); // requested as text, so we need to escape the string
        } catch (JavaScriptException e) {
            GWT.log("Unable to get the content from the TinyMCE editor.", e);
        }
    } else {
        result = super.getText();
        if (result == null || result.trim().isEmpty()) {
            result = "";
        } else {
            result = SafeHtmlUtils.fromString(result).asString();
        }
    }
    return result;
}
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
public void setHTML(SafeHtml html) {
    String text = html == null ? null: html.asString();
    if (libraryLoaded && (isInitialized() || isInitializing())) {
        if (isInitializing()) {
            pendingSetHtmlText = html;
            addPendingSetHtml();
            return;
        }
        try {
            setContent(elementId, text);
        } catch (JavaScriptException e) {
            // Don't do anything, just allow it to return.
            GWT.log("Unable to set the content on the TinyMCE editor.", e);
        }
        return;
    } else {
        super.setText(text);
    }
}
项目:forplay    文件:HtmlAssetManager.java   
@Override
protected void doGetText(final String path, final ResourceCallback<String> callback) {
  final String fullPath = pathPrefix + path;
  /*
   * Except for IE, all browsers support on-domain and cross-domain XHR via
   * {@code XMLHTTPRequest}. IE, on the other hand, not only requires the use
   * of a non-standard {@code XDomainRequest} for cross-domain requests, but
   * doesn't allow on-domain requests to be issued via {@code XMLHTTPRequest},
   * even when {@code Access-Control-Allow-Origin} includes the current
   * document origin. Since we here don't always know if the current request
   * will be cross domain, we try XHR, and then fall back to XDR if the we're
   * running on IE.
   */
  try {
    doXhr(fullPath, callback);
  } catch (JavaScriptException e) {
    if (Window.Navigator.getUserAgent().indexOf("MSIE") != -1) {
      doXdr(fullPath, callback);
    } else {
      throw e;
    }
  }
}
项目:gwt-jui    文件:JuiWrapper.java   
public void initialize() {
    Element element = getElement();
    initialize(element);

    Map<String, Object> failures = new HashMap<>();
    for(Map.Entry<String, Object> entry : optionFailures.entrySet()) {
        String option = entry.getKey();
        Object value = entry.getValue();
        try {
            setOption(element, option, value);
            logger.fine("Successfully set failed option: '" + option + "' to '" + value + "'");
        } catch (JavaScriptException ex) {
            failures.put(option, value);
            logger.log(Level.FINE, "Failed to set wrapper option", ex);
        }
    }
    optionFailures = failures;
}
项目:actor-platform    文件:PeerConnection.java   
@NotNull
@Override
public Promise<WebRTCSessionDescription> setRemoteDescription(@NotNull final WebRTCSessionDescription description) {
    return new Promise<>(new PromiseFunc<WebRTCSessionDescription>() {
        @Override
        public void exec(@NotNull final PromiseResolver<WebRTCSessionDescription> resolver) {
            peerConnection.setRemoteDescription(JsSessionDescription.create(description.getType(),
                    description.getSdp()), new JsClosure() {
                @Override
                public void callback() {
                    resolver.result(description);
                }
            }, new JsClosureError() {
                @Override
                public void onError(JavaScriptObject error) {
                    resolver.error(new JavaScriptException(error));
                }
            });
        }
    });
}
项目:dom-distiller    文件:JsTestSuiteBase.java   
private void logExceptionString(TestLogger logger, Throwable e) {
    StackTraceElement[] stack = e.getStackTrace();
    // The first stack frames are gwt internal exception creation functions that just make it
    // harder to see the real error. Skip them.
    int start = e instanceof JavaScriptException ? 1 : 4;
    if (debug) {
       start = 0;
    }
    int end = stack.length;
    logger.log(TestLogger.RESULTS, e.getMessage());
    for (int i = start; i < end; i++) {
        StackTraceElement ste = stack[i];
        if (debug) logger.log(TestLogger.WARNING, ste.toString());
        logger.log(TestLogger.RESULTS, "at " + stackFrameString(ste));
    }
}
项目:firefly    文件:Notifications.java   
public static void notify(String title, final String msg, final UserClick click ) {
    final String notifyTitle= (title==null) ? "Background Manager" : title;
    if (active && supported) {
        try {
            if (scriptLoaded) {
                notifyInternal(notifyTitle,msg);
            }
            else {
                loadJS(new InitComplete() {
                    public void done() {
                        notifyInternal(notifyTitle,msg);
                    }
                });
            }
        } catch (JavaScriptException e) {
            e.printStackTrace();
        }
    }
}
项目:gerrit    文件:PluginName.java   
String findCallerUrl() {
  JavaScriptException err = makeException();
  if (hasStack(err)) {
    return PluginNameMoz.getUrl(err);
  }

  String baseUrl = baseUrl();
  StackTraceElement[] trace = getTrace(err);
  for (int i = trace.length - 1; i >= 0; i--) {
    String u = trace[i].getFileName();
    if (u != null && u.startsWith(baseUrl)) {
      return u;
    }
  }
  return UNKNOWN;
}
项目:gerrit    文件:PluginName.java   
private static String getUrl(JavaScriptException e) {
  String baseUrl = baseUrl();
  JsArrayString stack = getStack(e);
  for (int i = stack.length() - 1; i >= 0; i--) {
    String frame = stack.get(i);
    int at = frame.indexOf(baseUrl);
    if (at >= 0) {
      int end = frame.indexOf(':', at + baseUrl.length());
      if (end < 0) {
        end = frame.length();
      }
      return frame.substring(at, end);
    }
  }
  return UNKNOWN;
}
项目:QMAClone    文件:StatusUpdater.java   
public void start() {
    if (isWebSocketUsed()) {
        try {
            webSocket = WebSocket.create(Constant.WEB_SOCKET_URL + path);
        } catch (JavaScriptException e) {
            // WebSocket is not supported.
        }
    }

    if (webSocket == null) {
        status = Status.RPC;
        Scheduler.get().scheduleFixedDelay(commandUpdate, intervalMs);
    } else {
        status = Status.WEB_SOCKET;
        webSocket.setOnMessage(messageHandler);
        webSocket.setOnClose(closeHandler);
        webSocket.setOnError(errorHandler);
    }
}
项目:gwt-storage    文件:StorageExt.java   
/**
 * Store the specified value with the specified key in this storage.
 *
 * <p>
 * Note: <code>null</code> value is not allowed. <br/>
 * If the storage previously contained a mapping for the key, the old
 * value is replaced.<br/>
 * {@link StorageKeyFactory} is preferred to get a {@link StorageKey} instance for primitive types.
 * </p>
 *
 * @param key key with which the specified value is to be associated
 * @param value value to be associated with the specified key
 * @throws SerializationException 
 * @throws StorageQuotaExceededException
 */
public <T> void put(StorageKey<T> key, T value) throws SerializationException, StorageQuotaExceededException {
  if(value == null){
    throw new NullPointerException();
  }
  try {
    String data = StorageUtils.serialize(key.getClazz(), value);
    // Update store and cache
    String oldData = storage.getItem(key.name());
    storage.setItem(key.name(), data);
    T oldValue = cache.put(key, value);
    fireEvent(StorageChangeEvent.ChangeType.PUT, key, value, oldValue, data, oldData);
  } catch (JavaScriptException e) {
    String msg = e.getMessage();
    if (msg != null && msg.contains("QUOTA") && msg.contains("DOM")) {
      throw new StorageQuotaExceededException(key, e);
    }
    throw e;
  }
}
项目:appinventor-extensions    文件:BlocklyPanel.java   
/**
 * Load the blocks described by blocksContent into the blocks workspace.
 *
 * @param formJson JSON description of Form's structure for upgrading
 * @param blocksContent XML description of a blocks workspace in format expected by Blockly
 * @throws LoadBlocksException if Blockly throws an uncaught exception
 */
// [lyn, 2014/10/27] added formJson for upgrading
public void loadBlocksContent(String formJson, String blocksContent) throws LoadBlocksException {
  try {
    doLoadBlocksContent(formJson, blocksContent);
  } catch (JavaScriptException e) {
    loadError = true;
    ErrorReporter.reportError(MESSAGES.blocksLoadFailure(formName));
    OdeLog.elog("Error loading blocks for screen " + formName + ": "
        + e.getDescription());
    throw new LoadBlocksException(e, formName);
  } finally {
    loadComplete = true;
  }
}
项目:appinventor-extensions    文件:BlocklyPanel.java   
/**
 * Get Yail code for current blocks workspace
 *
 * @return the yail code as a String
 * @throws YailGenerationException if there was a problem generating the Yail
 */
public String getYail(String formJson, String packageName) throws YailGenerationException {
  try {
    return doGetYail(formJson, packageName);
  } catch (JavaScriptException e) {
    throw new YailGenerationException(e.getDescription(), formName);
  }
}
项目:appinventor-extensions    文件:BlocklyPanel.java   
/**
 * Send component data (json and form name) to Blockly for building
 * yail for the REPL.
 *
 * @throws YailGenerationException if there was a problem generating the Yail
 */
public void sendComponentData(String formJson, String packageName) throws YailGenerationException {
  if (!currentForm.equals(formName)) { // Not working on the current form...
    OdeLog.log("Not working on " + currentForm + " (while sending for " + formName + ")");
    return;
  }
  try {
    doSendJson(formJson, packageName);
  } catch (JavaScriptException e) {
    throw new YailGenerationException(e.getDescription(), formName);
  }
}
项目:walkaround    文件:JsUtil.java   
public static JsoView eval(String data) throws MessageException {
  // TODO(danilatos): Use JSON.parse() instead of surrounding with parens
  // in browsers that support it.
  if (!data.startsWith("(")) {
    data = "(" + data + ")";
  }
  try {
    return evalNative(data);
  } catch (JavaScriptException e) {
    throw new MessageException(e);
  }
}
项目:Wiab.pro    文件:JsonMessage.java   
/**
 * Create a JsonMessage object from the given json
 * @param json The JSON String to load from.
 * @return true if evaluation is successful, false otherwise.
 */
public static JsonMessage createJsonMessage(String json) throws JsonException {
  try {
    JsonMessage obj = (JsonMessage) serializer.parse(json);
    registerNativeJsonMessageToString(obj);
    return obj;
  } catch (JavaScriptException e) {
    throw new JsonException(e);
  }
}
项目:Wiab.pro    文件:JsonMessage.java   
/**
 * Create a JsonMessage object from the given json
 * @param json The JSON String to load from.
 * @return true if evaluation is successful, false otherwise.
 */
public static JsonMessage createJsonMessage(RawStringData data) throws JsonException {
  try {
    JsonMessage obj = (JsonMessage) serializer.parse(data.getBaseString());
    JsonHelper.registerRawStringData(obj, data);
    registerNativeJsonMessageToString(obj);
    return obj;
  } catch (JavaScriptException e) {
    throw new JsonException(e);
  }
}
项目:Wiab.pro    文件:SelectionW3CNative.java   
public final void setAnchorAndFocus(Node anchorNode, int anchorOffset,
    Node focusNode, int focusOffset) {
  if (QuirksConstants.HAS_BASE_AND_EXTENT) {
    // NOTE(danilatos): While extend() would also work for webkit,
    // we have to use setBaseAndExtent because it appears to reuse
    // the existing range, rather than needing to replace it, and
    // doing otherwise stuffs up the IME composition state
    setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
  } else {

    // We assume that anchor node is in the same focusable area.
    // If not, death will ensue.
    setFocusElement(focusNode);

    // TODO(danilatos): Investigate just using extend() twice - i.e.
    // extend to the anchor -> collapse to end -> extend to the focus.
    JsRange range = JsRange.create();
    range.setStart(anchorNode, anchorOffset);
    range.collapse(true);

    removeAllRanges();
    addRange(range);

    if (focusNode != anchorNode || focusOffset != anchorOffset) {
      try {
          extend(focusNode, focusOffset);
      } catch (JavaScriptException e) {
        NativeSelectionUtil.LOG.error().logPlainText(
            "error extending selection from " + anchorNode + ":" + anchorOffset +
            " to " + focusNode + ":" + focusOffset);
        removeAllRanges();
        range = JsRange.create();
        range.setStart(anchorNode, anchorOffset);
        range.collapse(true);
        range.setEnd(focusNode, focusOffset);
        addRange(range);
      }
    }
  }
}
项目:Wiab.pro    文件:SelectionImplIE.java   
@Override
PointRange<Node> getOrdered() {
  // NOTE(user): try/catch here as JsTextRangeIE.duplicate throws an exception if the
  // selection is non-text, i.e. an image. Its much safer to wrap these IE native methods.
  // TODO(user): Decide whether returning null is the correct behaviour when exception is
  // thrown. If so, remove the logger.error().
  try {
    // Get selection + corresponding text range
    JsSelectionIE selection = JsSelectionIE.get();
    JsTextRangeIE start = selection.createRange();

    // Best test we have found for empty selection
    if (checkNoSelection(selection, start)) {
      return null;
    }

    // create two collapsed ranges, for each end of the selection
    JsTextRangeIE end = start.duplicate();
    start.collapse(true);
    end.collapse(false);

    // Translate to HtmlPoints
    Point<Node> startPoint = pointAtCollapsedRange(start);

    return JsTextRangeIE.equivalent(start, end) ? new PointRange<Node>(startPoint)
        : new PointRange<Node>(startPoint, pointAtCollapsedRange(end));
  } catch (JavaScriptException e) {
    logger.error().log("Cannot get selection", e);
    return null;
  }
}
项目:Wiab.pro    文件:DynamicDomRenderer.java   
@Override
protected void completeBlip(ConversationBlip blip) {
  if (isResizeControllerSupported) {
    try {
      resizeController.install(getMetaElementByBlip(blip));
    } catch (JavaScriptException ex) {
      DialogBox.information(messages.javaScriptError(ex.getMessage()) + "\n" +
          messages.upgradeBrowser());
      isResizeControllerSupported = false;
    }
  }    
}
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
public void setFocus(boolean focused) {
        if (!focused) {
            super.setFocus(focused); // nothing we can do to unset focus. Let GWT handle it.
            return;
        }

        try {
            // Only pass along the focus command 
            if (libraryLoaded && (isInitialized() || isInitializing())) {
                if (isInitializing()) {
                    // Setting a pending focus actually messes up the final focused element.
                    // This is because the async call always returns last, so any calls to setFocus
                    // for any other element essentially get ignored.
//                    if (focused) {
//                        addPendingSetFocus();
//                    }
                    return;
                }
                try {
                    setControlFocus(elementId);
                } catch (JavaScriptException e) {
                    GWT.log("Unable to set the focus on the TinyMCE editor.", e);
                }
                return;
            } 
        } finally {
            super.setFocus(focused);
        }
    }
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
public void setTabIndex(int tabIndex) {
    super.setTabIndex(tabIndex); // sets the tabIndex for the hidden associated textarea

    if (!libraryLoaded || !initialized) {
        // If not loaded or initialized, we're done.
        return;
    }

    try {
        // This will move the value in the textArea to the iframe
        setControlTabIndex(elementId);
    } catch (JavaScriptException e) {
        GWT.log("Unable to set the tab index on the TinyMCE editor iframe.", e);
    }    
}
项目:playn    文件:HtmlJson.java   
@Override
public Object parse(String json) throws JsonParserException {
  try {
    JavaScriptObject jsonParse = jsonParse(json);
    if (!isValueObject(jsonParse))
      throw new JsonParserException(null, "Input JSON was not an object", -1, -1, -1);
    HtmlObject object = (HtmlObject) unwrap0(jsonParse);
    return object;
  } catch (JavaScriptException e) {
    throw new JsonParserException(e, "Failed to parse JSON", -1, -1, -1);
  }
}
项目:playn    文件:HtmlJson.java   
@Override
public Array parseArray(String json) throws JsonParserException {
  try {
    JavaScriptObject jsonParse = jsonParse(json);
    if (!isValueArray(jsonParse))
      throw new JsonParserException(null, "Input JSON was not an array", -1, -1, -1);
    HtmlArray array = (HtmlArray) unwrap0(jsonParse);
    return array;
  } catch (JavaScriptException e) {
    throw new JsonParserException(e, "Failed to parse JSON", -1, -1, -1);
  }
}
项目:playn    文件:HtmlAssets.java   
@Override
public RFuture<String> getText(final String path) {
  final String fullPath = pathPrefix + path;
  /*
   * Except for IE, all browsers support on-domain and cross-domain XHR via
   * {@code XMLHTTPRequest}. IE, on the other hand, not only requires the use
   * of a non-standard {@code XDomainRequest} for cross-domain requests, but
   * doesn't allow on-domain requests to be issued via {@code XMLHTTPRequest},
   * even when {@code Access-Control-Allow-Origin} includes the current
   * document origin. Since we here don't always know if the current request
   * will be cross domain, we try XHR, and then fall back to XDR if the we're
   * running on IE.
   */
  try {
    return doXhr(fullPath, XMLHttpRequest.ResponseType.Default).
      map(new Function<XMLHttpRequest,String>() {
        public String apply (XMLHttpRequest xhr) {
          return xhr.getResponseText();
        }
      });
  } catch (JavaScriptException e) {
    if (Window.Navigator.getUserAgent().indexOf("MSIE") != -1) {
      return doXdr(fullPath).map(new Function<XDomainRequest,String>() {
        public String apply (XDomainRequest xdr) {
          return xdr.getResponseText();
        }
      });
    } else {
      throw e;
    }
  }
}
项目:gwt-jui    文件:Dependency.java   
public boolean isLoaded() {
    try {
        return loadCheck.loadCheck();
    } catch (JavaScriptException ex) {
        logger.log(Level.FINE, "Dependency load check threw: ", ex);
        return false;
    }
}
项目:gwt-jui    文件:JuiWrapper.java   
private void setNativeOption(Element e, String option, Object value) {
    try {
        setOption(e, option, value);
    } catch (JavaScriptException ex) {
        optionFailures.put(option, value);
    }
}
项目:che    文件:EditorInitializePromiseHolder.java   
private void injectOrion(final AsyncCallback<Void> callback) {
  loader.setMessage(waitEditorMessage);
  final String[] scripts =
      new String[] {"built-codeEdit/code_edit/built-codeEdit-amd", "orion/CheContentAssistMode"};

  requireJsLoader.require(
      new Callback<JavaScriptObject[], Throwable>() {
        @Override
        public void onSuccess(final JavaScriptObject[] result) {
          requireOrion(callback);
        }

        @Override
        public void onFailure(final Throwable e) {
          if (e instanceof JavaScriptException) {
            final JavaScriptException jsException = (JavaScriptException) e;
            final Object nativeException = jsException.getThrown();
            if (nativeException instanceof RequireError) {
              final RequireError requireError = (RequireError) nativeException;
              final String errorType = requireError.getRequireType();
              String message = "Orion injection failed: " + errorType;
              final JsArrayString modules = requireError.getRequireModules();
              if (modules != null) {
                message += modules.join(",");
              }
              Log.debug(OrionEditorExtension.class, message);
            }
          }
          initializationFailed(callback, "Failed to inject Orion editor", e);
        }
      },
      scripts,
      new String[0]);

  injectCssLink(
      GWT.getModuleBaseForStaticFiles() + "built-codeEdit/code_edit/built-codeEdit.css");
}
项目:che    文件:RequireJsLoader.java   
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);

  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);
}
项目:actor-platform    文件:PeerConnection.java   
@NotNull
@Override
public Promise<WebRTCSessionDescription> setLocalDescription(@NotNull final WebRTCSessionDescription description) {
    return new Promise<>(new PromiseFunc<WebRTCSessionDescription>() {
        @Override
        public void exec(@NotNull final PromiseResolver<WebRTCSessionDescription> resolver) {
            peerConnection.setLocalDescription(JsSessionDescription.create(description.getType(), description.getSdp()), () -> {
                resolver.result(description);
            }, error -> resolver.error(new JavaScriptException(error)));
        }
    }

    );
}
项目:firefly    文件:Notifications.java   
public static void requestPermission() {
    if (active && supported)  {
        try {
            requestPermissionInternal();
            loadJS(null);
        } catch (JavaScriptException e) {
            e.printStackTrace();
        }
    }
}
项目:google-apis-explorer    文件:CrossDomainRequest.java   
void handleResponse(DynamicJso response) {
  try {
    callback.onSuccess(ApiResponse.fromData(response));
  } catch (JavaScriptException e) {
    callback.onFailure(new HttpException("Unknown error"));
  }
}
项目:turbogwt-http    文件:RequestBuilder.java   
private void setHeaders(XMLHttpRequest xmlHttpRequest)
        throws RequestException {
    if (headers != null && headers.size() > 0) {
        for (Map.Entry<String, String> header : headers.entrySet()) {
            try {
                xmlHttpRequest.setRequestHeader(header.getKey(), header.getValue());
            } catch (JavaScriptException e) {
                throw new RequestException(e.getMessage());
            }
        }
    } else {
        xmlHttpRequest.setRequestHeader("Content-Type",
                "text/plain; charset=utf-8");
    }
}
项目:jpromises    文件:JsPromise.java   
private static Object toJsError(final Throwable exception) {
    if (exception instanceof JavaScriptException) {
        // unwrap and return inner error
        return ((JavaScriptException) exception).getThrown();
    } else {
        return toJsError0(exception, exception.getMessage());
    }
}