Skip to content

Commit

Permalink
Throw JS exception instead of Java wrapping object
Browse files Browse the repository at this point in the history
  • Loading branch information
Zbynek Konecny committed Dec 2, 2024
1 parent 6f9f451 commit a070d59
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions gwt-core/src/main/java/org/gwtproject/core/client/GWT.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import elemental2.dom.DomGlobal;
import elemental2.dom.Window;
import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
Expand Down Expand Up @@ -58,11 +59,10 @@ public static <T> T create(Class<?> clazz) {
public static void reportUncaughtException(Throwable e) {
// throw an exception "later" so that it ends up handled by the global
// error handler. Same code as in GWT2's Impl.reportToBrowser()
DomGlobal.setTimeout(
ignore -> {
throw_(e);
},
0);
setTimeout(
() -> {
throw e;
});
}

/**
Expand Down Expand Up @@ -160,8 +160,13 @@ private static class InnerWindow {
static Window window;
}

@JsMethod(namespace = "<window>", name = "throw")
private static native void throw_(Object object);
@JsFunction
private interface Throwing {
void run() throws Throwable;
}

@JsMethod(namespace = "<window>", name = "setTimeout")
private static native void setTimeout(Throwing throwingFunction);

public static boolean isClient() {
return org.gwtproject.core.shared.GWT.isClient();
Expand Down

0 comments on commit a070d59

Please sign in to comment.