cancel
Showing results for 
Search instead for 
Did you mean: 

catching activiti:expression errors/exception

workflowuser2
Champ in-the-making
Champ in-the-making
Could someone suggest a good strategy to catching exceptions in activiti:expression=#{foo.bar()}

In java delegates, you could catch exception (say ActivitiException) and throw BPMNError that triggers error path in the process.

How do we handle errors in the case of expressions?

thanks
Activiti newbie
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
If an expression or delegateExpression (as of 5.10, see http://jira.codehaus.org/browse/ACT-1159) throws an BPMNError, this is handled the same way. If it's another exception, this is bubbled up to the point where the activiti-api is called (your code).

If you want to mark "all" exceptions as being a logical BPMN error, I'm afraid there is no built-in way to do this. The only way is to make your beans that are evaluated in the expression, thow BPMNErrors. Another, more verbose way, if you don't want to include BPMNError in you beans (= keep it activiti-unaware or use existing services that you don't control the sources for), you should wrap all beans you want to expose in a dynamic-proxy which do a try/catch around all invoke-calls, wrapping the exceptions in a BPMNError instead of throwing the original one. OR create a service that only exposes the methods that you want to use, which delegates to the right bean and wraps thorn exceptions, if you don't want to go mess with proxies…