Nicholas
Nicholas

Reputation: 7501

Until successful failure expression that checks for multiple types of exceptions

In Mule, I'm using an until successful around an HTTP endpoint, to catch connection exceptions/timeouts. I'm catching 3 different Java exceptions:

I want to put the catching of these 3 into a failureExpression in my until-successful block, however when I try to do something like

I get an error that it cannot parse these. Is there any way I can specify for the failureExpression to check for multiple exception types?

Upvotes: 2

Views: 2998

Answers (2)

Nicholas
Nicholas

Reputation: 7501

I was able to achieve what I wanted using this:

failureExpression="#[exception != null && (exception.causedBy(java.net.ConnectException) || exception.causedBy(java.net.SocketTimeoutException) || exception.causedBy(java.net.SocketException))]"

My problem was the exception in the failure expression could be null, so I had to perform a null check.

Upvotes: 3

David Dossot
David Dossot

Reputation: 33413

This is not correct MEL syntax. It should be something like #[exception is Type1 || exception is Typ2].

See:

Upvotes: 1

Related Questions