3
votes

I have a JAX-RS service wrapped in a mule v3.2.1 flow which may trigger exceptions which I would like to capture and process. I would prefer to send the exception to another class and return an OutboundProperty with an http status of 500. Here's what I've got so far:

<flow name="someFlow">
    <...do some stuff...>
    <custom-exception-strategy class="com.myCustomExceptionHandler>
    </default-exception-strategy>
</flow>

myCustomExceptionHandler.handleException() is never called when I trigger an exception. And it is unclear to me how I repackage the mule message to return an http response.

Can anyone please provide some ideas on how to get this to work?

---- update ----

The exception will be a org.mule.api.expression.RequiredValueException, which is thrown when evaluate() is called by an instance of MuleExpressionManager inside a custom message processor:

public class RequestCheckWithAppMessageProcessor
implements FlowConstructAware, MuleContextAware, Disposable, Initialisable, Startable, Stoppable, MessageProcessor

The myCustomExceptionHandler class extends AbstractMessagingExceptionStrategy.

2

2 Answers

0
votes

Try removing the default-exception-strategy tag. I'm not very familiar with mule 3.2.1 but from the tests I get that the custom-exception-strategy should not be nested within the default one.

0
votes

Use catch-exception-strategy and write a custom Transformer to receive DefaultExceptionStrategy as exception payload in MuleMessage based on the Excption type, map error code