Conditional error processing
The Conditional error processing policy handles exception messages generated during runtime and enables you to define appropriate responses.
This policy lets you return a custom error message along with the native provider’s service fault to the calling application when a fault is received from the provider. You can configure conditions and use variables to craft dynamic, user-friendly error messages tailored to specific scenarios.
In IBM API Studio, this policy is identified by
the kind ErrorProcessing.
Example of an Conditional error erocessing policy:
kind: ErrorProcessing
apiVersion: api.ibm.com\v1
metadata:
name: httpbin
namespace: foo
spec:
condition: |
"(${response.headers.test} equals test1) or
(${request.headers.test} not-equals ${request.payload.jsonPath[$.customer.name]})"
pre-processing:
xsl:
- feature:
- name: test
value: value
$path: ./a/a.xsl
content: sdsd
transformations:
set:
- key: ${response.headers.h2}
value: test4
- key: ${request.query.q2}
value: ${response.payload.jsonPath[$.customer.name]}
setPayload:
content-types:
- application/json: |
{
"empid":"1"
}
- application/xml: |
<test></test>
- text/plain: |
"This is a plain content"
default-content-type: application/json
xsl:
- feature:
- name: test
value: value
$path: ./a/a.xsl
content: sdsd
namespaces:
- prefix: ps1
URI: http://test.com
- prefix: ps2
URI: http://test2.com
sendNativeError: true
post-processing:
xsl:
- feature:
- name: test
value: value
$path: ./a/a.xsl
content: sdsd
For the ErrorProcessing policy kind, configure these specifications:
| Type | Description |
|---|---|
spec |
This denotes various policy properties you can configure for the policy. You can
configure the following policy property:
|