Close this search box.

Global Error Handler Plugin in Mule 4

Mulesoft redesigned the whole error handling mechanism and components in Mule 4 (some key difference here). In Mule 3, there was a simple way to reuse a flow across multiple applications by putting into a separate mule-application and package that as jar. Jar can be added as a dependency in any mule-application.  An important application of this was having a reusable error response builder flow that possibly analyzes the exception and generates client friendly error response with the proper error code and error message for the REST API client.

However, Mule 4 does it a slightly different way. For reusing a flow, we need to create a Mule plugin and put the flow into that plugin. Any mule-application can add that plugin as maven dependency and reusable flow can be shared.

This article gives a step-by-step guide to generate that plugin in Mule 4 and installing into any mule-application.

  • Create a new mule project in Anypoint studio and go to pom.xml. Make sure the packaging set as mule-application. In our case the groupId is “com.plektonlabs” and the artifactId: “com-plektonlabs-utils-errorResponseBuilder”


  • Go to Build tag in pom.xml and make sure that the value extension tag is set as true and configuration->classifier is set as mule-plugin like the example below:














  • Implement your global error handler flow. In my case, I tried to create a global on-error-propagate handler to be able to reuse in each of my mule-application. The idea is to use this global-on-error-propagate flow in the API main flow in every project



Now, you can run the “mvn clean install” command in your command prompt and refer that as dependencies in your intended mule-application. if you need detail steps then follow my other article here:

Surprisingly enough, while writing this article I didn’t find any better way to achieve this reusability. I really wanted to have an error handler instead of implementing a flow. There is a component in Mule 4 named “Configuration” in which you can refer your error handler, like the following:


However, it does not find any flow from my reusable plugin. That’s the reason, I had to create shared flow.

Share This Post

More To Explore

How can we help?

A little about yourself and we're ready to go

We pride ourselves on swift communication and prompt responses. Let us know what you're thinking and how we can help you.

Contact Information​

Head Office
18 King Street E, Suite 1400, Toronto ON M5C 1C4, Canada

Durham Office
Unit 265, 1099 Kingston Rd. Pickering, ON. L1V1B5, Canada

Austin Office
5900 Balcones Dr, STE 4000 Austin, TX 78731, USA

Dallas Office
Unit 113, 320 Decker Drive, Irving, Texas, TX 75062, USA

Phone: +1(877) 855-8775

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.