throw
Use the throw construct to throw an error when it is reached during an assembly flow, usually as a result of a condition being reached.
Gateway support
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 your OpenAPI source; for details on how to configure the policy in the assembly user interface, see throw.
About
The throw policy has the following format:
- throw:
title: title
name: 'error_name'
error-status-code: http_status_code_for_error
error-status-reason: http_reason_phrase_for_error
message: error_message
When the throw policy is encountered, the specified error and error message is returned. If a catch has been configured that the error produced by the throw policy fulfills, the catch will be triggered.
Properties
Property | Required | Description | Data type |
---|---|---|---|
version | Yes | The policy version number | string |
title | No | A title for the policy. | string |
name | Yes | The name of the error to be thrown. | string |
error-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. |
integer |
error-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. |
string |
message | No | The message to accompany the error. | string |
Example
- throw:
version: 1.0.0
title: throw
name: '404'
message: Not found