Make logging less verbose
[gpl/argeo-suite.git] / org.argeo.app.core / src / org / argeo / app / ux / js / JsClient.java
index 060f1200856c94bb666d8d0c02562b7ee9764210..708daff143af5191d6fc76c5b5e36158a2ebcd52 100644 (file)
@@ -44,7 +44,7 @@ public interface JsClient {
        String createJsFunction(String name, Function<Object[], Object> toDo);
 
        /** Get a global variable name. */
-       public String getJsVarName(String name);
+       String getJsVarName(String name);
 
        /**
         * Completion stage when the client is ready (typically the page has loaded in
@@ -65,7 +65,12 @@ public interface JsClient {
        }
 
        default boolean isInstanceOf(String reference, String jsClass) {
-               return (Boolean) evaluate(getJsVarName(reference) + " instanceof " + jsClass);
+               try {
+                       return (Boolean) evaluate("return " + getJsVarName(reference) + " instanceof " + jsClass);
+               } catch (Exception e) {
+                       // TODO better understand why instanceof is often failing with SWT Browser
+                       return false;
+               }
        }
 
        /*