---
schema_version: "1"
id: 1c2acaf0530b85e446e19ac912f1b3ca39f0b514587d5821ee95d0e7cdce3b4e
title: Error Handler (<error-handler/>)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-code-builder/acb-component-error-handler.md
canonical_url: https://docs.mulesoft.com/anypoint-code-builder/acb-component-error-handler
source_site: docs.mulesoft.com
content_type: documentation
content_hash: b8ebfe182160c20b550b4c003ea34b27a6b75858acc9276bfd18b9bc9dfd94e4
description: MuleSoft Documentation Site
latest: true
---
---
product: Anypoint Code Builder
version: master
---

# Error Handler (<error-handler/>)

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Catches an error thrown by the Mule application and routes it to the first On-Error component
configuration that matches the error type.

The Error Handler component has two child elements, On Error Continue and On Error Propagate, which
enable you to configure routes that execute when the error raised in the application matches the
type of error configured in the handler. Each handler has its own behavior and works relative to the
component that contains it (a Flow or a Try scope):

- On Error Continue (`on-error-continue`): executes and uses the result of the execution as the
  result of its container element (as if the container completed the execution successfully). Any
  transactions at this point commit successfully.

- On Error Propagate (`on-error-propagate`): rolls back any transactions, executes, and uses that
  result to rethrow the existing error. In this case, the container element "fails" its execution.

If there’s no error handling configuration that matches the error, the app follows a default error
handling process. See
[Using Default Error Handling for Messages](https://docs.mulesoft.com/mule-runtime/latest/error-handling#default_error_handling)
for more information.

## Component XML

This component supports the following XML structure:

```xml
<flow name="myFlow">

    <error-handler>
      <on-error-propagate name="onErrorPropagate" >
        <!-- error handling logic -->
      </on-error-propagate>
      <on-error-continue name="onErrorContinue" >
        <!-- error handling logic -->
      </on-error-continue>
    </error-handler>

</flow>
```

Error Handler (`<error-handler/>`) attributes are configurable through the UI and XML.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Error handler</strong> (default)</p></td><td><p><code>doc:name</code></p></td><td><div><div><p>Editable name for the component to display in the canvas.</p></div></div></td></tr><tr><td><p>N/A</p></td><td><p><code>doc:id</code></p></td><td><div><div><p>Automatically generated identifier for the component.</p></div></div></td></tr></tbody></table>

The `<on-error-continue/>` and `<on-error-propagate/>` child elements share the following
attributes:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>When</strong></p></td><td><p><code>when</code></p></td><td><div><div><p>A matching expression that defines the condition to trigger the execution of this on-error strategy. The expression must evaluate to a Boolean value (<code>true</code> or <code>false</code>).</p></div></div></td></tr><tr><td><p><strong>Type</strong></p></td><td><p><code>type</code></p></td><td><div><div><p>A comma-separated list of Mule error types that defines the errors this on-error strategy handles.</p></div></div></td></tr><tr><td><p><strong>Log exception</strong></p></td><td><p><code>logException</code></p></td><td><div><div><p>Specifies whether to log the error at level <code>ERROR</code> before this strategy handles it. Defaults to <code>true</code>.</p></div></div></td></tr><tr><td><p><strong>Enable notifications</strong></p></td><td><p><code>enableNotifications</code></p></td><td><div><div><p>Specifies if this strategy triggers a notification of type <code>ExceptionNotification</code> when an error occurs. Defaults to <code>true</code>.</p></div></div></td></tr></tbody></table>

## Error Handling Example

The following example configures handlers to produce
`{ "MyError": "value was expected to be null" }` for a `VALIDATION:NOT_NULL` error and
`{ "messageANY" : "Some other error" }` for other error types.

```xml
<error-handler >
  <on-error-continue
    enableNotifications="true"
    logException="true"
    type="VALIDATION:NOT_NULL">
    <ee:transform >
      <ee:message>
        <ee:set-payload>
        <![CDATA[%dw 2.0
        output application/json
        ---
        {
        MyError : error.description as String
        }]]>
        </ee:set-payload>
      </ee:message>
    </ee:transform>
  </on-error-continue>
  <on-error-continue
    enableNotifications="true"
    logException="true"
    type="ANY">
    <ee:transform>
      <ee:message >
        <ee:set-payload >
        <![CDATA[%dw 2.0
        output application/json
        ---
        {
        "messageANY" : "Some other error"
        }
        ]]>
        </ee:set-payload>
      </ee:message>
    </ee:transform>
  </on-error-continue>
</error-handler>
```

## See Also

- [Mule Errors](https://docs.mulesoft.com/mule-runtime/latest/mule-error-concept)

- [Mule Runtime Engine Notifications](https://docs.mulesoft.com/mule-runtime/latest/mule-server-notifications)
