About Handling Errors

APIkit 4.0 replaces exception strategy and error mapping with the Mule Runtime 4.0 error handler. This error handler uses error types as shown in the code snippet below. Each error response is generated using DataWeave.

<apikit:router config-ref="api-config" />
    <on-error-propagate type="APIKIT:BAD_REQUEST">
        <ee:transform xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
                <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>

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Give us your feedback!
We want to build the best documentation experience for you!
Help us improve with your feedback.
Take the survey!