Raise Error Assertion

Used by itself, the Raise Error Assertion stops policy execution and provides an error that policy execution is stopped. If a Raise Error Assertion is inside a Handle Error Assertion, execution stops at the Raise Error point, but execution of the policy continues outside of the Handle Error Assertion block.
gateway83
Used by itself, the
Raise Error Assertion
stops policy execution and provides an error that policy execution is stopped. If a Raise Error Assertion is inside a Handle Error Assertion, execution stops at the Raise Error point, but execution of the policy continues outside of the Handle Error Assertion block.
 
Though it is not possible to set your own error message in the Raise Error Assertion, you can set a context variable before the assertion to pass information to the internal error handler about what went wrong. If used within a global policy or a encapsulated assertion context, be sure to use the Export Variables from Fragment Assertion to make the context variable available to the parent policy
The following is an example of how the Raise Error Assertion could work with the Handle Error Assertion:
- All assertions must evaluate to true
    - Handle Errors
         - At least one
            - Route to
<wherever>
            - All assertions must evaluate to true (//routing failed)
               - Set variable "errorCause" as String to "routing failed: ${httpRouting.reasonCode}"
               - Export Variable from Fragment "errorCause" (//this exports to "request.shared.errorCause")
               - Raise Error
    - All assertions must evaluate to true (// an error was caught)
       - <add logic to check ${request.shared.errorCause} to see what went wrong>
In this simple example, exporting the variable "errorCause" to "request.shared.errorCause" is not necessary because the entire fragment is within the same policy scope. Where this would be required is a scenario similar to the following:
  • The Raise Error Assertion is located in a policy fragment serving as the underlying policy for an encapsulated assertion.
  • The Handle Error Assertion is located outside of the encapsulated assertion.
Context Variables
None
Cluster Properties
None