Contact Free trial Login

APIkit Error Handling Reference

APIkit generates error-handling code based on the main error handling mechanism in Mule 4. If something goes wrong with a component, you get an error that is typed accordingly with a message. The generated code is available for the most widely-used HTTP status code responses, which are mapped to the types and error messages in the following table.

Status Code Type Message



Bad request



Resource not found



Method not allowed



Not acceptable



Unsupported media type

The following example of the HTTP 400 response shows the construction of the error handler. To add your own custom status code, following the pattern shown here.

 <on-error-propagate type="APIKIT:BAD_REQUEST" doc:name="On Error Propagate">
                <ee:transform xmlns:ee="" xsi:schemaLocation="">
                        <ee:set-payload><![CDATA[%dw 2.0
output application/json
{message: "Bad request"}]]></ee:set-payload>
                        <ee:set-variable variableName="httpStatus">400</ee:set-variable>

Every time a message throws an error, APIkit checks to see if the error matches the value of any on-error-propagate types defined in the project. The main flow in an APIkit project sends an HTTP error response consisting of an HTTP status code and corresponding plain-language message.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.