August 28, 2008

Pages


Search Site


Topics


Useful Links

Blogs I Read


Archives

Catching Java Exceptions In ColdFusion

April 22 2008 by Andrew Powell

When you are using custom java objects in your ColdFusion code, often times these objects will throw custom exceptions. These exceptions, like all others, should be handled gracefully. So how do you listen for custom java exceptions in ColdFusion? Let's consider the exception "java.lang.NullPointerException". We can listen for this specific type of exception with the code below:

<cftry>
      <!---
         some operation on your java object
      --->

      <cfcatch type="java.lang.NullPointerException">
         <!--- error handling code --->
      </cfcatch>
   </cftry>

Since java.lang.NullPointerException extends java.lang.Exception, you could easily swap the two in the type attribute of CFCATCH and get the same results. So if you are working with Spring and/or Hibernate, this makes it easier to catch and handle exceptions that you may come across in your java code.

Posted in Java | ColdFusion | General | Universal Mind | 0 comments

0 responses to “Catching Java Exceptions In ColdFusion”

Leave a Reply