Throw

Generates an error that can be handled by a Try construct.

Use the Throw policy to generate an error intentionally when required conditions are not met. The thrown error can be handled by a Try construct to provide controlled failure behavior.

For more information on the policy parameter descriptions, see DataPower Nano Gateway documentation.

Example of a Throw policy in code view.

kind: Throw
apiVersion: api.ibm.com/v1
metadata:
  name: throw-bad-request
  namespace: sample
  version: 1.0
spec:
  # (1/5) BadRequestError
  error: "BadRequestError"
---
kind: Throw
apiVersion: api.ibm.com/v1
metadata:
  name: throw-connection-error
  namespace: sample
  version: 1.0
spec:
  # (2/5) ConnectionError
  error:
    connectionError:
      cause: ''
      causeType: 'variables' # variables | plain | jsonata
---
kind: Throw
apiVersion: api.ibm.com/v1
metadata:
  name: throw-custom-error
  namespace: sample
  version: 1.0
spec:
  error:
    customError:
      message: '' 
      messageType: 'plain' # plain | variables | jsonata
      status: 400
---
kind: Throw 
apiVersion: api.ibm.com/v1
metadata:
  name: throw-limit-exceed-error
  namespace: sample
  version: 1.0
spec:
  error:
    limitExceededError:
      name: ''
      nameType: 'plain' # plain | variables | jsonata
---
kind: Throw
apiVersion: api.ibm.com/v1
metadata:
  name: throw-validate-error
  namespace: sample
  version: 1.0
spec:
  error:
    validateError:
      message: ''
      messageType: 'plain' # plain | variables | jsonata
---