Name

GetException

Synopsis

                  
                  GetException(object_name)

Used in conjunction with try/catch code, GetException( ) returns a Java exception object thrown by the specified object. The following example shows how to use GetException( ) with an imaginary Java object called MyObject:

<cfobject type="Java" action="Create" class="MyClass" name="MyObject">
   
<cfset Test = MyObject.init( )>
<cftry>
<cfset Test = MyObject.CauseError( )>
   
<cfcatch type="Any">
   <cfset MyException = GetException(MyObject)>
   <!--- call the GetErrCode and GerErrMsg methods within the exception
         object --->
   <cfset ErrorCode = MyException.GetErrCode( )
   <cfset ErrorMessage = MyException.GetErrMsg( )>
   
   <cfoutput>
     Error Code: #ErrorCode#<br>
     Error Message: #ErrorMessage#
   </cfoutput>
</cfcatch>
</cftry>

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.