0
votes

We are using WSO2 integration studio for our integration solution. We are trying to throw exceptions in some cases during the mediation flow and route the mediation flow to the fault sequence. Is it possible to implement it?

1

1 Answers

0
votes

You can directly call the Fault sequence from wherever you want in the mediation. It is similar to calling a normal sequence.

However to have a more programmatic approach, you can define a Call Template mediator with parameters. You can do write a standard Fault template and call this template wherever you want. With this approach you can pass any custom error messages and codes from anywhere in the mediation. A sample template is shown below.

<template name="utils_fault_handler" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="errorMessage"/>
<parameter name="errorCategory"/>
<parameter name="errorId"/>
<sequence>
    <log category="ERROR" level="custom">
        <property expression="$func:errorId" name="ERROR_CODE"/>
        <property expression="$func:errorCategory" name="ERROR_CATEGORY"/>
        <property expression="$func:errorMessage" name="ERROR_MESSAGE"/>
    </log>
    <respond/>
</sequence>