Handling exceptions

Use the cftry and cfcatch tags to catch CORBA object method exceptions thrown by the remote server, as follows:

  1. Specify type="coldfusion.runtime.corba.CorbaUserException" in the cfcatch tag to catch CORBA exceptions.

  2. Use the cfcatch.getContents method to get the contents of the exception object.

The cfcatch.getContents method returns a ColdFusion structure containing the data specified by the IDL for the exception.

The following code example shows the IDL for a CORBA object that raises an exception defined by the PrimitiveException exception type definition, and the CFML that catches the exception and displays the contents of the object.

IDL

interface myInterface 
{ 
exception PrimitiveException 
{ 
long l; 
string s; 
float f; 
}; 
void testPrimitiveException() raises (PrimitiveException); 
}

CFML

<cftry> 
<cfset ret0 = handle.testPrimitiveException()> 
<cfcatch type=coldfusion.runtime.corba.CorbaUserException> 
<cfset exceptStruct= cfcatch.getContents()> 
<cfdump var ="#exceptStruct#"> 
</cfcatch> 
</cftry>