This documentation is for WSO2 API Manager 1.10.0 View documentation for the latest release.
Page Comparison - Error Handling (v.4 vs v.5) - API Manager 1.10.0 - WSO2 Documentation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In addition to the above error codes, we have engaged Synapse-level error codes to the default fault sequence and custom fault sequences (e.g.,_token_fault_.xml) of the API Manager. For information, see Error Handling in WSO2 ESB documentation.

 

Custom Error Message with Custom HTTP Status Code for Throttled-out Messages

 If you need to send a custom message with custom HTTP status code we may execute additional sequence which can generate new error message. There we can override message body, HTTP status code etc. Following example demonstrates how we can override the throttle out message's HTTP status code.

 

Go to <APIM_HOME>/repository/deployment/server/synapse-configs/default/sequences directory and create the file convert.xml as follows.

Code Block
languagexml
titleconvert.xml
<?xml version="1.0" encoding="UTF-8"?><sequence xmlns="http://ws.apache.org/ns/synapse" name="convert">
    <payloadFactory media-type="xml">
        <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 evaluator="xml" expression="$ctx:ERROR_CODE"/>
            <arg evaluator="xml" expression="$ctx:ERROR_MESSAGE"/>
        </args>
    </payloadFactory>
    <property name="RESPONSE" value="true"/>
    <header name="To" action="remove"/>
    <property name="HTTP_SC" value="555" scope="axis2"/>
    <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="Access-Control-Allow-Origin" value="*" scope="transport"/>
    <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/>
</sequence>

 

 

Tip

Alternatively you can use source view to add it to synapse configuration.

To do that follow the below steps.

  1. Start the API Manager and log in to Management Console. (https://<Server Host>:9443/carbon).
  2. Go to Manager --> source view.
  3. Copy the content of the sequence in convert.xml and paste as a new sequence in the source view and update it.

...