<sequence xmlns="http://ws.apache.org/ns/synapse" name="json_fault">
    <log level="custom">
        <property name="STATUS" value="Executing custom 'fault' sequence"/>
        <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
        <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
    </log>
    <payloadFactory>
        <format>
            <am:fault xmlns:am="http://wso2.org/apimanager">
                <am:code>$1</am:code>
                <am:type>Status report</am:type>
                <am:message>Runtime Error</am:message>
                <am:description>$2</am:description>
            </am:fault>
        </format>
        <args>
            <arg expression="$ctx:ERROR_CODE"/>
            <arg expression="$ctx:ERROR_MESSAGE"/>
        </args>
    </payloadFactory>
    <filter xpath="$ctx:CUSTOM_HTTP_SC">
        <then>
            <property name="HTTP_SC" expression="$ctx:CUSTOM_HTTP_SC" scope="axis2"/>
        </then>
        <else>
            <property name="HTTP_SC" value="500" scope="axis2"/>
        </else>
    </filter>
    <class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtFaultHandler"/>
    <property name="RESPONSE" value="true"/>
    <header name="To" action="remove"/>
    <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
    <property name="ContentType" scope="axis2" action="remove"/>
    <property name="Authorization" scope="transport" action="remove"/>
    <property name="Host" scope="transport" action="remove"/>
    <property name="Accept" scope="transport" action="remove"/>
    <property name="X-JWT-Assertion" scope="transport" action="remove"/>
    <property name="messageType" value="application/json" scope="axis2"/>
    <send/>
    <drop/>
</sequence>