<try>
<!-- COMPONENTS TO TRY TO USE -->
<error-handler>
<on-error-continue>
<!-- COMPONENTS TO USE IN CASE OF ERROR -->
</on-error-continue>
<on-error-propagate>
<!-- COMPONENTS TO USE IN CASE OF ERROR -->
</on-error-propagate>
</error-handler>
</try>
Try Scope XML Reference
Standard Support for Mule 4.1 ended on November 2, 2020, and this version of Mule reached its End of Life on November 2, 2022, when Extended Support ended. Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted. MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements. |
A Try scope follows the structure described below.
-
A single root element
<try>
-
Components that are executed under the error-handling rules defined by the Try scope are defined as child elements of the
try
element. You can place one or many here. -
A single
<error-handler>
element holds all error handling strategies for the scope. -
In the error handler, one or several
on-error-continue
andon-error-propagate
define the various strategies. At least one of these must be present. -
Components that are executed when a matching error occurs are defined as child elements of the
on-error
element. You can place one or many here.
Each error handling strategy in a Try scope (on-error-*
) follows a condition. This condition is typically an error type (or a list of several) which must match the current error. You can also define this condition as a freely written expression, such as error.cause.message.contains("fatal")
.
Note that conditions are evaluated in order and only the first strategy to match is executed. |
Below is an example that includes two error handling strategies, each executing a logger component:
<try>
<http:request config-ref="HTTP-config" method="GET" path="/" />
<error-handler>
<on-error-continue enableNotifications="true" logException="true" type="CONNECTIVITY">
<logger level="INFO" doc:name="Logger" message="Connectivity Error"/>
</on-error-continue>
<on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" type="EXPRESSION">
<logger level="INFO" doc:name="Logger" message="Expression error" />
</on-error-propagate>
</error-handler>
</try>
Properties of Try
Property | Default | Description |
---|---|---|
|
INDIFFERENT |
Defines if what’s in the scope is treated as a transaction. Possible values:
|
|
LOCAL |
Defines the type of transaction to use. Possible values:
|