Contents > Developing ColdFusion MX Applications > Integrating J2EE and Java Elements in CFML Applications > Using Java objects > Handling Java exceptions Example: exception-throwing class PreviousNext

Example: exception-throwing class

The following Java code defines the testException class that throws a sample exception. It also defines a myException class that extends the Java built-in Exception class and includes a method for getting an error message.

The myException class has the following code. It throws an exception with a message that is passed to it, or if no argument is passed, it throws a canned exception.

//class myException
public class myException extends Exception 
{
   public myException(String msg) {
      super(msg);
   }
   public myException() {
      super("Error Message from myException");
   }
}

The testException class contains one method, doException, which throws a myException error with an error message, as follows:

public class testException {
   public testException () 
   {
   }
   public void doException() throws myException {
        throw new myException("Throwing an exception from testException class");
    }
}

Contents > Developing ColdFusion MX Applications > Integrating J2EE and Java Elements in CFML Applications > Using Java objects > Handling Java exceptions Example: exception-throwing class PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.