Charu Khurana
Charu Khurana

Reputation: 4551

How to best handle different types of exception thrown in mule flow

I've an http service exposed in my Mule 3.3.0 flow. Now, I want to return different response on different exceptional conditions like want to differentiate if error is because of malformed xml versus incorrect input values or the error is on server side like jms is down. How can I best handle this in flow.

I tried creating private flow which catches exception and applies transformer for the desired response. When the control comes back to the calling main flow, the returned exception of private flow is treated as payload message and continues with the rest of processing. The exception returned from private flow is not returned as response of http service (as my flow is exposing http service)

Is there a way to stop the rest of flow if an exception has occurred in private flow?

I put xml verification in private flow because I want to differentiate error message thrown to user based on if its server or client error

Upvotes: 1

Views: 1069

Answers (2)

Anshu Sk Mishra
Anshu Sk Mishra

Reputation: 36

Catch Exception Strategy is the best one according to me, bcz it can be referred, and it can also be called in a choice exception.

Upvotes: 0

David Dossot
David Dossot

Reputation: 33413

Since the exception is processed in the private flow, you need to use standard message routing to change the processing path of the parent flow based on the outcome of the private flow.

For example, you can use a choice router after the flow-ref call and, based on the presence of some properties (or whatever makes sense in your case), either keep with the processing or return the response immediately.

Upvotes: 1

Related Questions