[automation] Improve rule debugging (#1742)

* Add rule UID to error message
* Add exception with stacktrace when debug level is enabled

Related to #1734

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2020-10-20 15:50:25 +02:00
committed by GitHub
parent d262b6f5bc
commit 584c85a07f
2 changed files with 3 additions and 2 deletions
@@ -57,7 +57,7 @@ public abstract class AbstractScriptModuleHandler<T extends Module> extends Base
private final String type;
protected final String script;
private final String ruleUID;
protected final String ruleUID;
public AbstractScriptModuleHandler(T module, String ruleUID, ScriptEngineManager scriptEngineManager) {
super(module);
@@ -62,7 +62,8 @@ public class ScriptActionHandler extends AbstractScriptModuleHandler<Action> imp
Object result = scriptEngine.eval(script);
resultMap.put("result", result);
} catch (ScriptException e) {
logger.error("Script execution failed: {}", e.getMessage());
logger.error("Script execution of rule with UID '{}' failed: {}", ruleUID, e.getMessage(),
logger.isDebugEnabled() ? e : null);
}
});