Exception
Values of Exception type are objects that contain information about runtime errors.
Usage
The Exception type is defined in the com.apama.exceptions namespace. Typically, you specify using com.apama.exceptions.Exception so you can easily refer to Exception objects.
An Exception object has methods for accessing an error message, an error type, and a sequence of com.apama.exceptions.StackTraceElement objects that show where the exception occurred and what the calls were that led to the exception.
You cannot route an Exception object, but a routable object can have an Exception object as a member.
Methods
The following methods may be called on values of Exception type:
getMessage() — returns a string that contains the exception message.
getStackTrace() — returns a
sequence of
StackTraceElement objects that represent the stack trace for when the exception was first thrown. The sequence is empty if the exception has not been thrown.
getType() — returns a string that contains the exception type, which is one of the following:
Exception Type | Description | Example |
ArithmeticException | Illegal arithmetic operations | Attempt to divide by 0, call to the ceil() method on NaN, call to the exponent() method on infinity, specifying NaN as all or part of an ordered key, call to the rand() method on an illegal float value such as Infinity |
DefaultContextException | Spawning, sending or enqueuing to a context and specifying a context variable that has been declared but the context has not yet been created | monitor m { context c; action onload() { send A() to c; } } |
IndexOutOfBoundsException | Invalid index in a sequence or string operation | sequence.insert(-1, x) |
IllegalArgumentException | Illegal argument value in an expression | "".split() |
IllegalStateException | Calling an action when it is illegal to do so | spawn statement in ondie() or onunload() |
MemoryAllocationException | Unable to fulfill memory allocation request | An invalid size is passed to the sequence setCapacity() method |
NullPointerException | Attempt to call an action variable when that variable has not been initialized | event E { action<string> x; } monitor m { E e; action onload() { e.x("This will fail!"); } } |
OtherInternalException | An internal error occurred | parse("two") on an integer |
ParseException | Error that occurs while parsing | |
PluginException | An exception thrown by a correlator plug-in. See the note that follows this table. | |
StackOverflowException | Attempt to use more space than is available on the stack | |
In C++ correlator plug-ins, you can customize exception types so that the type returned has this format:
PluginException:user_defined_type
See AP_UserPluginException in the correlator_plugin.hpp file in the include folder of your Apama installation.
In Java plug-ins, the exception type returned has this format:
PluginException:class_name
For example:
import "MyJavaPlugin" as myjavaplugin;
...
action myAction() {
try {
myjavaplugin.processfile("config.txt");
} catch (Exception e) {
log "Exception of type "
+ e.getType() at WARN;
}
}
...
Returns something like:
Exception of type
PluginException:java.io.FileNotFoundException
toString() — returns a string that contains the exception message and the exception type.
toStringWithStackTrace() — returns a string that contains the exception message, the exception type, and the stack trace elements.