throw

Use the throw policy to throw an error when it is reached during the execution of an assembly flow.

Gateway support

Table 1. Table showing which gateways support this policy, and the corresponding policy version
Gateway Policy version
DataPower® Gateway (v5 compatible) 1.0.0
DataPower API Gateway 2.0.0

2.1.0 (DataPower API Gateway Version 10.0.3.0 or later)

This topic describes how to configure the policy in the assembly user interface; for details on how to configure the policy in your OpenAPI source, see throw.

When the throw policy is encountered, the specified error and error message is produced.

If a catch has been configured that the error produced by the throw policy fulfills, the catch will be triggered.

If no catch is triggered by the thrown error, then a 500 Internal Server Error is returned to the API caller.

Component property details

You can configure a component's properties in the property sheet in the assemble view.

Table 2. The properties of a throw component
Property Required Description
Title No A custom title for your component when it is displayed in the canvas. If a title is not specified, throw is used by default.
Error name Yes The error name that is thrown by the policy.
DataPower API Gateway
onlyError status code (policy version 2.1.0 and later) No Specify the HTTP status code for the error. You can use the $(variable) format to reference the message.status.code API context variable.
DataPower API Gateway
onlyError status reason (policy version 2.1.0 and later) No Specify the HTTP reason phrase for the error. You can use the $(variable) format to reference the message.status.reason API context variable.
Error message No The error message that is returned with the error name.