Example usage for com.google.gwt.core.client JavaScriptException JavaScriptException

List of usage examples for com.google.gwt.core.client JavaScriptException JavaScriptException

Introduction

In this page you can find the example usage for com.google.gwt.core.client JavaScriptException JavaScriptException.

Prototype

public JavaScriptException(String name, String description) 

Source Link

Usage

From source file:asquare.gwt.tk.client.util.JsUtil.java

License:Apache License

/**
 * Get an int value from a native JavaScript array.
 * /*from   w w  w  .j  a  v  a 2 s . c  o  m*/
 * @param array an opaque handle to a JavaScript array
 * @param index the index, starting at 0
 * @return the value
 * @throws JavaScriptException if the array is null
 * @throws JavaScriptException if the index is out of bounds
 * @throws JavaScriptException if value at the index is not coercable to an
 *             int (hosted mode only)
 */
public static int arrayGetInt(JavaScriptObject array, int index) {
    try {
        return arrayGetInt0(array, index);
    } catch (RuntimeException e) {
        throw new JavaScriptException(null, e.getMessage());
    }
}

From source file:asquare.gwt.tk.client.util.JsUtil.java

License:Apache License

/**
 * Get a float value from a native JavaScript array.
 * /* ww  w. j  a va2 s. c o  m*/
 * @param array an opaque handle to a JavaScript array
 * @param index the index, starting at 0
 * @return the value
 * @throws JavaScriptException if the array is null
 * @throws JavaScriptException if the index is out of bounds
 * @throws JavaScriptException if value at the index is not coercable to a
 *             float (hosted mode only)
 */
public static float arrayGetFloat(JavaScriptObject array, int index) {
    try {
        return arrayGetFloat0(array, index);
    } catch (RuntimeException e) {
        throw new JavaScriptException(null, e.getMessage());
    }
}

From source file:asquare.gwt.tk.client.util.JsUtil.java

License:Apache License

/**
 * Get an object from a native JavaScript array.
 * /* ww w. j  av a 2 s  . co  m*/
 * @param array an opaque handle to a JavaScript array
 * @param index the index, starting at 0
 * @return the value
 * @throws JavaScriptException if the array is null
 * @throws JavaScriptException if the index is out of bounds
 * @throws JavaScriptException if value at the index is not an object
 *             (hosted mode only)
 */
public static Object arrayGetObject(JavaScriptObject array, int index) {
    try {
        return arrayGetObject0(array, index);
    } catch (IllegalArgumentException e) {
        throw new JavaScriptException(null, e.getMessage());
    }
}

From source file:com.allen_sauer.gwt.log.client.impl.LogImplBase.java

License:Apache License

static JavaScriptException convertJavaScriptObjectToException(JavaScriptObject e) {
    return new JavaScriptException(javaScriptExceptionName(e), javaScriptExceptionDescription(e));
}

From source file:playn.html.HtmlAssetManager.java

License:Apache License

private void doXhr(final String fullPath, final ResourceCallback<String> callback) {
    XMLHttpRequest xhr = XMLHttpRequest.create();
    xhr.setOnReadyStateChange(new ReadyStateChangeHandler() {
        @Override/* w  ww .ja v a  2 s  .  c  o  m*/
        public void onReadyStateChange(XMLHttpRequest xhr) {
            int readyState = xhr.getReadyState();
            if (readyState == XMLHttpRequest.DONE) {
                int status = xhr.getStatus();
                // status code 0 will be returned for non-http requests, e.g. file://
                if (status != 0 && (status < 200 || status >= 400)) {
                    PlayN.log().error("xhr::onReadyStateChange[" + fullPath + "](readyState = " + readyState
                            + "; status = " + status + ")");
                    callback.error(
                            new RuntimeException("Error getting " + fullPath + " : " + xhr.getStatusText()));
                } else {
                    if (LOG_XHR_SUCCESS) {
                        PlayN.log().debug("xhr::onReadyStateChange[" + fullPath + "](readyState = " + readyState
                                + "; status = " + status + ")");
                    }
                    // TODO(fredsa): Remove try-catch and materialized exception once issue 6562 is fixed
                    // http://code.google.com/p/google-web-toolkit/issues/detail?id=6562
                    try {
                        callback.done(xhr.getResponseText());
                    } catch (JavaScriptException e) {
                        if (GWT.isProdMode()) {
                            throw e;
                        } else {
                            JavaScriptException materialized = new JavaScriptException(e.getName(),
                                    e.getDescription());
                            materialized.setStackTrace(e.getStackTrace());
                            throw materialized;
                        }
                    }
                }
            }
        }
    });

    if (LOG_XHR_SUCCESS) {
        PlayN.log().debug("xhr.open('GET', '" + fullPath + "')...");
    }
    xhr.open("GET", fullPath);

    if (LOG_XHR_SUCCESS) {
        PlayN.log().debug("xhr.send()...");
    }
    xhr.send();
}