Skip to content

Commit

Permalink
Improve errors for scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphr committed Nov 30, 2023
1 parent 5ec89d6 commit 5e6aefa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.StringJoiner;

public class DefaultScriptTrace implements ScriptTrace, ScriptTraceEnhancer.ScriptTraceContext {

Expand Down Expand Up @@ -62,4 +63,14 @@ public Map<String, String> getTraceTags() {
public Duration getDuration() {
return duration;
}

@Override
public String toString() {
return new StringJoiner(", ", DefaultScriptTrace.class.getSimpleName() + "[", "]")
.add("duration=" + duration)
.add("request=" + request)
.add("exception=" + exception)
.add("traceTags=" + traceTags)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.LinkedList;
import java.util.List;
import java.util.StringJoiner;

import org.flowable.common.engine.api.FlowableIllegalStateException;
import org.flowable.common.engine.api.variable.VariableContainer;
Expand Down Expand Up @@ -183,4 +184,14 @@ public List<Resolver> getAdditionalResolvers() {
public ScriptTraceEnhancer getTraceEnhancer() {
return traceEnhancer;
}

@Override
public String toString() {
return new StringJoiner(", ", ScriptEngineRequest.class.getSimpleName() + "[", "]")
.add("language='" + language + "'")
.add("script='" + script + "'")
.add("variableContainer=" + variableContainer)
.add("storeScriptVariables=" + storeScriptVariables)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected Object evaluate(ScriptEngine scriptEngine, ScriptEngineRequest request
} catch (ScriptException e) {
DefaultScriptTrace scriptTrace = DefaultScriptTrace.errorTrace(Duration.ofNanos(System.nanoTime() - startNanos), request, e);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Caught exception evaluating script. {}{}{}", request.getLanguage(), System.lineSeparator(),
LOGGER.debug("Caught exception evaluating script for {}. {}{}{}", request.getVariableContainer(), request.getLanguage(), System.lineSeparator(),
request.getScript());
}
enhanceScriptTrace(request, scriptTrace);
Expand All @@ -115,7 +115,7 @@ protected void notifyScriptTraceListener(ScriptTraceListener listener, ScriptTra
try {
listener.onScriptTrace(scriptTrace);
} catch (Exception e) {
LOGGER.warn("Exception while executing scriptTraceListener: {}", e.getMessage(), e);
LOGGER.warn("Exception while executing scriptTraceListener: {} with {}", listener, scriptTrace, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected void safelyExecuteScript(DelegateExecution execution) {
try {
executeScript(execution);
} catch (FlowableException e) {
LOGGER.warn("Exception while executing {} : {}", execution.getCurrentFlowElement().getId(), e.getMessage());
LOGGER.warn("Exception while executing {} : {}", execution, e.getMessage());

noErrors = false;
Throwable rootCause = ExceptionUtils.getRootCause(e);
Expand Down

0 comments on commit 5e6aefa

Please sign in to comment.