Mule 4 Mulesoft Tutorial

Error Handling In Mule 4

In this tutorial of “Error Handling In Mule 4” we will be understand about various types of error handling and how we can implement it in our project with an example.

There are 3 types of error handling mechanism in Mule 4.

  1. On Error Continue
  2. On Error Propagate
  3. Try Catch Scope

On Error Continue

On-Error Continue catches the error, and do not report it as an error; thus the processing of the flow continues even after the error has occurred. This error handler can be used in flows where you don’t want to stop the flow processing even if an error has occurred.

For example in the below flow, the parent flow will execute till the end even if web consumer has returned an error.

SchedulerFlow is calling flow callWebService flow, in case of any error at point 9 (at web service consumer) the flow will process as follows: 1->2->3->7->8->9->12->13->4.
Here at point 13 the error is send to its parent flow (SchedulerFlow) as flow message, and parent flow executes its processing further.

On Error Propagate

On Error Propagate works exactly as Mule 3 Catch exception strategy. In case on any error, On Error Propagate processes the error message and re-throws the error to its parent flow. No further processing is done on that particular flow.

For example in the below Flow, when flow execution starts, point 1, 2, 3 will execute first, on error at point 3 the error is catch by on-error propagate and error processing begins with point 6, 7; once the error handling flow is completed the flow processing ends and an error is re-thrown to its parent flow.

In can of no error or happy scenario point 1,2,3,4,5 are executed, in case of error at point 3; point 1,2,3,6,7 are executed.

In the second example below, SchedulerFlow is calling flow callWebService flow, in case of any error at point 9 (at web service consumer) the flow will process as follows: 1->2->3->7->8->9->12->13->5->6.
Here at point 13 the error is thrown to its parent flow (SchedulerFlow), and parent flow error handler is invoked.

Try Catch Scope

Try catch scope can be used within a flow to do error handling of just inner components. Try catch scope can be very useful in cases where we want to add separate error processing strategy for various components in the flow.

For example: In case of error at point 3 (at web service consumer) the flow will process as follows: 1->2->3->7->8->10->11.
In case of error at point 5 (at saleforces connector) the flow will process as follows: 1->2->3->4->5->9->6.


Configuring On-Error Continue and On-Error Propagate

As in Mule 3 we had to specify which error is to be catch inside the catch exception strategy, same we can do in Mule 4 with even more control.

In Mule 4 we can specify Error Type and/or When Condition which when is evaluated true that particular error handler is executed. In case none error handler catches the error the error is re-thrown to its parent flow. 

Error Type: This matches with the type of error that is thrown. Error Type are auto populated based on connectors used in the flow. It contains the list of errors that the connectors can throw in the flow.


When Condition: The expression that will be evaluated to determine if the exception strategy could be executed. This should always be boolean expression. 

In below example when variable errorCount is greater than 3 then only that particular error handler is invoked.

About Varun Goel

Varun Goel is a technology enthusiast with 6+ years exp in IT industry. In fact, he is been developing application after schooling as freelancer. Currently working with one of the Fortune’s 100 Companies having vast experience Mule ESB, Tibco, HTML5, CSS, JSS, Android, Core Java, JSP, PHP, MySQL, AutoCAD, Maya, ZBrush, Photoshop, Flash CS and many more.


  1. Armando Gandia

    Just wish to say your article is as amazing. The clearness in your post is simply nice and i could assume you are an expert on this subject. Fine with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please keep up the rewarding work.

  2. Beard Oil Natural

    In this grand design of things you’ll secure an A with regard to effort. Where you misplaced me was in your facts. As they say, details make or break the argument.. And that could not be much more true right here. Having said that, allow me say to you exactly what did work. Your article (parts of it) is certainly rather powerful and this is possibly the reason why I am making the effort to opine. I do not make it a regular habit of doing that. Second, whilst I can easily notice the jumps in reason you make, I am not sure of exactly how you seem to connect the details which in turn produce your conclusion. For right now I will subscribe to your issue but wish in the near future you actually connect the facts much better.

  3. Jasmin Macha

    I have been exploring for a little bit for any high-quality articles or blog posts on this sort of house . Exploring in Yahoo I at last stumbled upon this web site. Studying this information So i’m glad to exhibit that I have an incredibly just right uncanny feeling I found out exactly what I needed. I most undoubtedly will make sure to do not omit this site and give it a look on a continuing basis.

  4. Betsey

    A person will not test a pack that is clearly leaking, while they
    understand it will fail, thereby distorting the real profile
    of the production run, while a piece of equipment
    will collect the sample and report the result objectively.
    Customers will find that GPR reduces quality surveys allow architects and
    structural engineers to design buildings around subterranean composition. Methods add a soap solution, a halide torch, dye interception,
    isolation of an component from the system, or pressurizing the device with dry
    nitrogen gas.


    Perhaps precisely what are needed are less subject-specific biostatistics courses,
    which put more emphasis upon the main reasoning of statistical analysis.
    This is possible since math could be used to compute
    for the likelihood of a team provided the correct variables are considered.
    In conclusion, both of these types are quite crucial in data collection.

  6. Lakiesha Biggs

    Hello there, I discovered your site by way of Google while searching for a comparable topic, your website got here up, it appears to be like great. I’ve bookmarked it in my google bookmarks.

  7. How Do I what is arbitrage

    When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get three emails with the same comment. Is there any way you can remove people from that service? Bless you!

  8. How Do I amazon fba 2020

    Hi! This is kind of off topic but I need some guidance from an established blog. Is it very hard to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking about making my own but I’m not sure where to start. Do you have any tips or suggestions? With thanks

  9. creativeitguys

    I am having trouble bubbling up a custom error from SYS Api( try( insert into db) –> ON ERROR PROPAGATE —> RAISE ERROR (APP:DBConnectivity)) from my Sys API to Process API. I am supposed to do remediation in Process API if I encounter this error (APP:DBConnectivity) .Unfortunately doesn’t look like this custom error bubbles up to the process api and it gets converted to default error (HTTP:INTERNAL_SERVER_ERROR) which I am not expecting as I need to catch specific error that was raised in my Sys API.

  10. Xali Beut

    Very well explained Varun! Thanks a lot.
    Also, you may add some other stuffs in the picture, which could add another level of complexity:
    – global error
    – private flow

    And finally, sharing a project with your examples would be great”

  11. Sri Charan

    This is a copied article, Please create and share genuine article.Do not do for business. Otherwise you will land in a ditch sometime.

Leave a Reply

Your email address will not be published.