use of com.google.gwt.core.client.JavaScriptException in project che by eclipse.
the class RequireJsLoader method require.
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);
}
use of com.google.gwt.core.client.JavaScriptException in project rstudio by rstudio.
the class EditSnippetsDialog method attemptSaveAndClose.
private void attemptSaveAndClose() {
// record pending edits
recordEditorState();
// check for edits we need to save
JsArray<SnippetData> changedSnippets = JsArray.createArray().cast();
for (int i = 0; i < snippetTypes_.getItemCount(); i++) {
EditableSnippets snippets = snippetTypes_.getItemAtIdx(i);
String edits = snippets.getPendingEdits();
if (edits != null) {
String mode = snippets.getEditorMode();
JavaScriptException ex = SnippetHelper.loadSnippetsForMode(mode, edits);
if (ex != null) {
snippetTypes_.setSelectedIndex(i);
globalDisplay_.showErrorMessage("Error Applying Snippets (" + snippets.getFileTypeLabel() + ")", ex.getDescription());
// early return (don't close dialog)
return;
}
changedSnippets.push(SnippetData.create(mode, edits));
}
}
// perform the save then close the dialog
if (changedSnippets.length() > 0) {
server_.saveSnippets(changedSnippets, new VoidServerRequestCallback() {
@Override
protected void onSuccess() {
closeDialog();
}
});
} else {
closeDialog();
}
}
use of com.google.gwt.core.client.JavaScriptException in project playn by threerings.
the class HtmlAssets method doXhr.
private void doXhr(final String fullPath, final Callback<String> callback) {
XMLHttpRequest xhr = XMLHttpRequest.create();
xhr.setOnReadyStateChange(new ReadyStateChangeHandler() {
@Override
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.onFailure(new RuntimeException("Error getting " + fullPath + " : " + xhr.getStatusText()));
} else {
if (LOG_XHR_SUCCESS) {
PlayN.log().debug("xhr::onReadyStateChange[" + fullPath + "](readyState = " + readyState + "; status = " + status + ")");
}
// http://code.google.com/p/google-web-toolkit/issues/detail?id=6562
try {
callback.onSuccess(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();
}
use of com.google.gwt.core.client.JavaScriptException in project playn by threerings.
the class HtmlJson method parse.
@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);
}
}
use of com.google.gwt.core.client.JavaScriptException in project playn by threerings.
the class HtmlJson method parseArray.
@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);
}
}
Aggregations