Throwing Exception from custom Java function in TIBCO BusinessEvents.

Throwing Exception from custom Java function in TIBCO BusinessEvents.

book

Article ID: KB0091123

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -
Not Applicable -

Description

Resolution:
Description:
===========
Throwing Exception from custom Java function in TIBCO BusinessEvents .

Environment:
===========
All Operating Systems
TIBCO BusinessEvents 4.x,5.x


Resolution:
===========
TIBCO BusinessEvents supports throwing only RuntimeException from custom Java code . Note that any other exception thrown from custom Java code has to be wrapped as an instance of Runtime Exception.

Custom Function Code :

public static void exceptionThrow() throws RuntimeException
{
    try
    {
        int a = 7 / 0; // This line will throw arithmetic exception
        System.out.println("Quotient" + String.valueOf(a));
    }
    catch (Exception exception)
    {
        if (exception instanceof RuntimeException)
        {
            throw new RuntimeException(); //Throws runtime exception
        }
        else
        {
            //Wrap any other exception into an instance of runtime exception before throwing
            throw new RuntimeException("Not a runtime Exception", exception);
        }
    }
}

Catalog Function for the exceptionThrow method :

&ltfunction>
    &ltname&gtReturnThrow</name>
    &ltmethod&gtexceptionThrow</method>
    &ltclass&gtcom.test.ObjectReturn</class>
    &ltasync&gtfalse</async>
    &ltreevaluate&gttrue</reevaluate>
    &ltisActionOnly&gttrue</isActionOnly>
    &lttooltip>
        &ltsynopsis&gtReturns nothing</synopsis>
        &ltreturns type='void'></returns>
    </tooltip>
</function>


TIBCO BusinessEvents sample code to catch exception thrown from custom code :

try
{
    Testing.ReturnThrow();
}
catch (Exception e)
{
    System.debugOut("In catch");
}

Issue/Introduction

Throwing Exception from custom Java function in TIBCO BusinessEvents.