CFCatch Java Exceptions
June 12, 2009

Did you know that you can catch java exceptions by class name with cfcatch? It's not documented on the cfcatch tag documentation (as of CF8), but it works... Here's an example:
<cftry>
<cfset list = CreateObject("java", "java.util.LinkedList")>
<cfset list.get(5)>
<cfcatch type="java.lang.IndexOutOfBoundsException">
Index outta bounds
</cfcatch>
</cftry>
There is one special exception that Mark Mandel has blogged about, and that is if the exception is caused by a class that was loaded by a different classloader, cfcatch won't be able to catch it by type. Perhaps that's why this feature is undocumented?
Tweet
Trackbacks
Trackback Address: 699/B94A286A99BFE4FB187C8EEFBA63C9A8
Post a Comment
Spell Checker by Foundeo
Recent Entries
- Nginx redirect www to non www domain
- HashDOS and ColdFusion
- HackMyCF Updated for APSB11-29 Security Hotfix
- Adobe eSeminar on FuseGuard
- Determining Which Cumulative Hotfixes are Installed on ColdFusion
- Adding Two Factor Authentication to ColdFusion Administrator
- ColdFusion Developer Week at Adobe.com
- Bug Loading Scripts for CFFileUpload and CFMediaPlayer


add to del.icio.us



