Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
package org.gwtproject.core.client;

import com.google.gwt.junit.client.GWTTestCase;
import elemental2.dom.DomGlobal;
import java.util.ArrayList;
import java.util.List;

public class GWTTest extends GWTTestCase {

private List<Throwable> caught = new ArrayList<>();

@Override
public String getModuleName() {
return "org.gwtproject.core.Core";
Expand All @@ -32,4 +38,22 @@ public void testIsClient() {
assertTrue(GWT.isClient());
assertTrue(org.gwtproject.core.shared.GWT.isClient());
}

public void testReportUncaughtError() {
GWT.setUncaughtExceptionHandler(caught::add);
GWT.reportUncaughtException(new RuntimeException());
DomGlobal.setTimeout(
(ignore) -> {
assertEquals(1, caught.size());
assertEquals("java.lang.JsException", caught.get(0).getClass().getName());
finishTest();
},
1000);
delayTestFinish(3000);
}

@Override
public boolean catchExceptions() {
return false;
}
}
2 changes: 1 addition & 1 deletion gwt-core/src/main/java/org/gwtproject/core/client/GWT.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private static void addOnErrorHandler(Window window, Window.OnerrorFn onerrorFn)
@JsMethod
private static native Throwable fromObject(Object obj) /*-{
//GWT2 impl using JSNI, see GWT.native.js for the j2cl impl
var throwable = @java.lang.Throwable::of(*)(obj);
return @java.lang.Throwable::of(*)(obj);
}-*/;

@JsType(isNative = true, name = "window", namespace = "<window>")
Expand Down
Loading