From a070d593849a26ff55bedd99a8ece0a80da69e5e Mon Sep 17 00:00:00 2001 From: Zbynek Konecny Date: Mon, 2 Dec 2024 18:43:14 +0100 Subject: [PATCH] Throw JS exception instead of Java wrapping object --- .../java/org/gwtproject/core/client/GWT.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gwt-core/src/main/java/org/gwtproject/core/client/GWT.java b/gwt-core/src/main/java/org/gwtproject/core/client/GWT.java index d8fea32..8b50ce9 100644 --- a/gwt-core/src/main/java/org/gwtproject/core/client/GWT.java +++ b/gwt-core/src/main/java/org/gwtproject/core/client/GWT.java @@ -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; @@ -58,11 +59,10 @@ public static 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; + }); } /** @@ -160,8 +160,13 @@ private static class InnerWindow { static Window window; } - @JsMethod(namespace = "", name = "throw") - private static native void throw_(Object object); + @JsFunction + private interface Throwing { + void run() throws Throwable; + } + + @JsMethod(namespace = "", name = "setTimeout") + private static native void setTimeout(Throwing throwingFunction); public static boolean isClient() { return org.gwtproject.core.shared.GWT.isClient();