|
ION Java User's Guide: Building ION Applets and Applications |
|
When the ION Server detects an error, it throws an exception value you can detect and act upon using error-handling code. Consult the reference page for the method you are using to determine which exceptions ION can detect in a given situation.
Error handling is generally accomplished via a Java try/catch code segment. The following skeleton try/catch code illustrates how to catch exceptions and display an error message on the Java console. For a more detailed example, see Simple Applet Example.
| Note If an ION method (or any Java method, for that matter) throws a checked exception value, you must handle the exception in your code. The Java compiler will complain if you do not properly handle all possible exception values. Refer to a Java manual for more information on Java exception handling. |
try{
some ION command
}catch(IOException e) {
// IO Error
System.err.println("Error: Communication error:
"te.getMessage());
return;
}catch( IONIllegalCommandException e){
// Illegal Command
System.err.println("Error: Illegal Command:
"te.getMessage());
return;
}catch( IONSecurityException e){
// Security Violation
System.err.println("Error: Security Violation:
"te.getMessage());
return;
}
}
IDL Online Help (March 06, 2007)