Skip to content

Commit 3d0410b

Browse files
committed
Changed exception handling (issue #955)
1 parent 22ceea5 commit 3d0410b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

imixs-workflow-core/src/main/java/org/imixs/workflow/ModelManager.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.imixs.workflow.bpmn.BPMNUtil;
2929
import org.imixs.workflow.exceptions.ModelException;
3030
import org.imixs.workflow.exceptions.PluginException;
31+
import org.imixs.workflow.exceptions.ProcessingErrorException;
3132
import org.openbpmn.bpmn.BPMNModel;
3233
import org.openbpmn.bpmn.BPMNNS;
3334
import org.openbpmn.bpmn.elements.Activity;
@@ -293,7 +294,16 @@ public ItemCollection nextModelElement(BPMNModel model, ItemCollection event, It
293294
node -> ((BPMNUtil.isImixsTaskElement(node))
294295
|| (BPMNUtil.isImixsEventElement(node))
295296
|| (BPMNUtil.isParallelGatewayElement(node))),
296-
condition -> evaluateCondition(condition, workitem));
297+
condition -> {
298+
try {
299+
return evaluateCondition(condition, workitem);
300+
} catch (ModelException e) {
301+
// catch Model Exception and translate it into a Runtime Exception because of
302+
// the Lambda expression used here
303+
throw new ProcessingErrorException(e.getErrorContext(), e.getErrorCode(), e.getMessage(),
304+
e);
305+
}
306+
});
297307

298308
while (elementNavigator.hasNext()) {
299309
BPMNElementNode nextElement = elementNavigator.next();
@@ -689,18 +699,16 @@ public String findDataObject(ItemCollection bpmnElement, String name) {
689699
* @param workitem the workflow item providing context data for condition
690700
* evaluation
691701
* @return true if the condition evaluates to true, false otherwise
702+
* @throws ModelException
692703
*/
693-
public boolean evaluateCondition(String expression, ItemCollection workitem) {
694-
704+
public boolean evaluateCondition(String expression, ItemCollection workitem) throws ModelException {
695705
// delegate expression to the runtime
696706
String finalExpression = this.workflowContext.evalConditionalExpression(expression, workitem);
697707
try {
698708
return getRuleEngine().evaluateBooleanExpression(finalExpression, workitem);
699709
} catch (PluginException e) {
700-
e.printStackTrace();
701-
logger.severe("Failed to evaluate Condition: " + e.getMessage());
710+
throw new ModelException(e.getErrorCode(), e.getMessage(), e);
702711
}
703-
return false;
704712
}
705713

706714
/**

imixs-workflow-core/src/main/java/org/imixs/workflow/exceptions/ProcessingErrorException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.imixs.workflow.exceptions;
1717

1818
/**
19-
* An ProcessingErrorException is a RuntimeExcption thrown by the
19+
* An ProcessingErrorException is a RuntimeException thrown by the
2020
* workflowManager if an error occurs during the process method
2121
*
2222
* @author rsoika

0 commit comments

Comments
 (0)