Listing 1: You can centralize exception handling regardless of where the exception occurs
TRY
exception ex
ex = CREATE exception
CHOOSE CASE ai_exCode
CASE 1
ex.SetMessage("This is CODE 1")
Throw(ex)
CASE 2
ex.SetMessage("This is CODE 2")
Throw(ex)
CASE 3
ex.SetMessage("This is CODE 3")
Throw(ex)
CASE ELSE
MessageBox("Hmmm...", "I take no exception to this...")
END CHOOSE
CATCH (exception excp)
string ls_msg
ls_msg = excp.GetMessage()
MessageBox("An exception has occurred", ls_msg)
FINALLY
MessageBox("And Finally", "Here we are...")
END TRY
RETURN ai_exCode
Listing 2: If you deploy a component that throws "exception", you'll get an error message
---------- Deploy: Deploy of p_pbexception_eascomps
Doing Incremental Rebuild ...
Generating IDL For Selected Components ...
Defining Interface IDL In Repository ...
Generation Messages:
Deployment Error Adding Component IDL For Package 'p3_test' EAServer
error code: SystemException: com.sybase.CORBA.idl.SyntaxError: file
'p3_test::pbexception', line 4: '`': expected ','
---------- Finished Deploy of p_pbexception_eascomps
Listing 3: The public instance variable messagetext holds the exception's message
short thing;
try
{
thing = exception_test.of_exception();
out.print(thing);
}
catch (p3_test.userexception ue)
{
out.println("<BR>An exception occurred<BR>");
out.println(ue.messagetext);
out.println("<BR>");
}