WSO2 BPS - Sample Guide - Fault Handling

Sample Guide - Fault Handling

Table of Content


Objective

This sample explains about basic fault handling. In fault handling, <throw/> and <rethrow/> are used to generate faults where faults occurs.

Note - <faultHandlers/> should be defined in a parent scope.


Prerequisites


Overall Idea

Refer - TestThrowCatchFaultHandling.zip

In the child scope the input value is checked whether it's equal to 1. If so an InputException1 is thrown. Note that the thrown exception has a "saw:InputException1" qualified name.

eg -

<ifname="ExceptionCondition1"><condition>number($value)=number(1)</condition><throwfaultName="saw:InputException1"/><else><throwfaultName="saw:TransitionConditionOutOfRangeException1"/></else></if>

In the parent scope the exception is filtered against its qualified name.

eg -

<faultHandlers><catchfaultName="saw:InputException1"><ifname="ExceptionCondition2"><condition>true()</condition><throwfaultName="saw:InputException2"/><else><throwfaultName="saw:TransitionConditionOutOfRangeException2"/></else></if></catch></faultHandlers>