Use the catch section of the assembly to describe the handling of errors thrown during
the assembly execution.
About this task
You can complete this task either by using the API Designer UI application, or by using the
browser-based API
Manager UI.
The catch section of the assembly is used to implement an assembly in the instance that an error
is thrown during the assembly execution. For example, the assembly could contain a
throw
element, the API caller could fail to authenticate, or a policy could fail to
execute correctly. Each error can be handled with a different catch and each catch can handle
multiple status errors.
Procedure
To create a catch and include elements in it, complete the following
steps:
-
In the navigation pane, click
Develop, then select the APIs tab.
The Develop page
opens.
-
Click the title of the API definition that you want to apply a catch to.
- Select the Gateway tab, then click
Policies in the navigation pane.
-
Set the Show catches toggle in the menu bar of the canvas to the
Show position.
-
Click Catches in the canvas, or a Catch icon
if one is displayed.
The property sheet for the API's catches opens.
-
To add a default catch that is executed when an otherwise uncaught error is thrown, click
Add default catch.
Note: If you have a default catch before another catch in precedence, the default catch will
activate even when the other catch's error is thrown.
-
To add a new catch, click Add catch.
-
To specify which errors the catch applies to, use the Select errors
field and select the appropriate error.
- Optional:
To remove an error case from a catch, clear the corresponding checkbox from the
Select errors drop-down. To clear all the error cases from a catch, click the
cross corresponding to the total number of error cases in the Select errors
field.
- Optional:
To change the precedence of your catches, use the Move up
or Move down
icons.
If an error case is handled by multiple catches, the catch at the beginning of the list is
applied.
-
To add an element to a catch from the palette, click the plus icon at the appropriate location in the assembly flow. Select an element that you
want to apply to the catch by clicking it.
-
Click Save to save your changes.
What to do next
If you added a catch for ConnectionError,
SOAPError, or OperationError, you must add the same
error to the Stop on error setting for the Invoke
policy in
your assembly. Otherwise, if the error occurs during the execution of the Invoke
policy, it is not caught, the policy execution is allowed to complete, and the assembly flow
continues. For details on configuring an Invoke
policy, see Invoke.
For details of all the errors that can be returned by the assembly and are available to the catch
function, see Error cases supported by assembly catches.