[jsscripting] Fix regressions from #14135 & Log stack on IllegalArgumentException (#14142)

* [jsscripting] Fix bundling of global script & regression from #14135

Fixes the regression from https://github.com/openhab/openhab-addons/pull/14135#issuecomment-1369231126.

While working on this, I also noticed that the cache openhab-js does not work because of wrong webpack commandline args in the pom (wrong entrypoint).

* [jsscripting] Enable stack logging for IllegalArgumentExceptions
* [jsscripting] Upgrade openhab-js to 3.2.4
* [jsscripting] Update README for recent PR

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This commit is contained in:
Florian Hotze
2023-01-03 20:45:23 +01:00
committed by GitHub
parent 7c3fbfdde3
commit f082df923f
4 changed files with 19 additions and 6 deletions

View File

@@ -39,6 +39,9 @@ class DebuggingGraalScriptEngine<T extends ScriptEngine & Invocable & AutoClosea
@Override
public Exception afterThrowsInvocation(Exception e) {
Throwable cause = e.getCause();
if (cause instanceof IllegalArgumentException) {
STACK_LOGGER.error("Failed to execute script:", e);
}
if (cause instanceof PolyglotException) {
STACK_LOGGER.error("Failed to execute script:", cause);
}

View File

@@ -71,7 +71,6 @@ public class OpenhabGraalJSScriptEngine
private static final Logger LOGGER = LoggerFactory.getLogger(OpenhabGraalJSScriptEngine.class);
private static Source GLOBAL_SOURCE;
static {
try {
GLOBAL_SOURCE = Source.newBuilder("js", getFileAsReader("node_modules/@jsscripting-globals.js"),
@@ -82,7 +81,6 @@ public class OpenhabGraalJSScriptEngine
}
private static Source OPENHAB_JS_SOURCE;
static {
try {
OPENHAB_JS_SOURCE = Source
@@ -92,7 +90,7 @@ public class OpenhabGraalJSScriptEngine
throw new RuntimeException("Failed to load @openhab-globals.js", e);
}
}
private static String OPENHAB_JS_INJECTION_CODE = "Object.assign(this, require('openhab'));";
private static final String OPENHAB_JS_INJECTION_CODE = "Object.assign(this, require('openhab'));";
private static final String REQUIRE_WRAPPER_NAME = "__wraprequire__";
/** Final CommonJS search path for our library */