Pictorial view of Mule 4 Error Handling
I have created a series of articles on Mule 4 Error handling with simple examples to explain how the flow control moves when an error is encountered. In the series of articles, I have used Is number component which validates whether the incoming payload is an integer or not. If the payload is not an integer the error gets populated. Hope this article clears the confusion if you have between On Error Continue and On Error Propagate in the Error handler
How Global Error Handler works in Mule 4?
How Default Error Handling in Mule 4 works?
How On Error Continue works in Mule 4?
How On Error Propagate works in Mule 4?
Default Error Handling in Mule 4

Default error handling is invoked when there are no custom-defined error handlers like Global error handler or Custom error handler. When an error occurs the default error handler acts as On Error Propagate component which stops the further flow executes and responds the client with an error.
On Error Continue
When we use the On Error Continue component it processes all the message processors which are part of it and terminates the flow. Interestingly, the error response code returned is 200

On Error Propagate
When On Error Propagate is invoked, It processes all the components within it and rethrows the error event to the calling flow. In this scenario, the error code will be the original error code that was generated by the component. Here components can be any connector, scope, router, filter, validators, etc..

Global Error Handling On Error Propagate
Global Error Handling is used to handle the errors at the application level. The above scopes are related to flow level errors. I have created another article for Global error handling. We can create a flow specific to handle all errors and configure the expected scenarios using error handlers. This flow can be referred to by all flows in a Mule application to use as a Global Error Handler.

Global Error Handling On Error Continue

Private Flow On Error Propagate
This scenario is to understand how the flow control switches between a private flow and the main flow.

Private Flow On Error Continue

Private Flow On Error Propagate & Main Flow On Error Continue

Apart from the above we also have a Try Scope component in Mule 4 which can be used to handle the errors at the message processor level.
0 Comments