BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
77 / 81 · Module 18 — Interview Coding Scenarios · filtered: interview← prev⊞ allnext →

18.15Scenario 14 — Raise custom business error

Prompt:

“Reject customers missing customerId.”

Conceptually:

<choice>

    <when expression="#[payload.customerId == null]">

        <raise-error
            type="APP:INVALID_CUSTOMER"
            description="customerId is required"/>

    </when>

</choice>

You can also use Mule Validation components.

The point is:

business/domain error
→ APP:INVALID_CUSTOMER

rather than leaking a random Java exception.