com.apama.exceptions
Type Exception


Exceptions that can be thrown and caught within EPL.

Values of Exception type are objects that contain information about runtime errors.

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.

Exceptions can be constructed with the Exception constructor, which takes a string for the message and a string for the exception type. Any string can be used for the type, but it is recommended to re-use one of the types generated by the correlator when appropriate.

Exceptions can be thrown with the throw operator. For example:
throw Exception("No readings", "IllegalArgumentException");
You cannot route an Exception object, but a routable object can have an Exception object as a member.

Exceptions can be caught using the try…catch syntax:
try {
        
methodThatThrows();
} catch(com.apama.exceptions.Exception e) {
// handle the exception here
}
Exceptions can be parsed, routed and compared. They are not cyclic.
Action summary
 booleanstatic canParse(string s)

Check whether it is possible to parse the string argument as an exception.
 com.apama.exceptions.Exceptionclone()

Create a deep copy of this exception.
 stringgetMessage()

Get the message in this exception.
 sequence<com.apama.exceptions.StackTraceElement>getStackTrace()

Get the stack trace at the point this exception was thrown.
 stringgetType()

Get the type of this exception.
 integerhash()

Get an integer hash representation of the underlying object.
 com.apama.exceptions.Exceptionstatic parse(string s)

Parse a string as an exception.
 stringtoString()

Return a string form of the exception.
 stringtoStringWithStackTrace()

Format this exception and the stack trace.
 
Action detail

canParse

            boolean static canParse(string s)
        
Check whether it is possible to parse the string argument as an exception.
Parameters:
s - The string to check for parseability.
Returns:
True if it would be possible to parse this string as an exception, false otherwise.
See Also:
com.apama.exceptions.Exception#parse() - See the parse documentation for the string form.

clone

            com.apama.exceptions.Exception clone()
        
Create a deep copy of this exception.
Returns:
A deep copy of this exception.

getMessage

            string getMessage()
        
Get the message in this exception.
Returns:
The string message in this exception.

getStackTrace

            sequence<com.apama.exceptions.StackTraceElementgetStackTrace()
        
Get the stack trace at the point this exception was thrown.
Returns:
A sequence of StackTraceElement objects corresponding to the EPL stack from where this exception was thrown.

getType

            string getType()
        
Get the type of this exception.

The valid exception types are:

ArithmeticException Illegal arithmetic operations.
Example: 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.
CastException Thrown when casting an any value to a type which does not match the type of the any value.
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.
IndexOutOfBoundsException  Invalid index in a sequence or string operation.
IllegalArgumentException Illegal argument value in an expression.
IllegalStateException Calling an action when it is illegal to do so. For example, a spawn statement in ondie() or onunload().
MemoryAllocationException  Unable to fulfill memory allocation request. For example, an invalid size is passed to the sequence setCapacity() method.
NullPointerException Attempt to call an action variable when that variable has not been initialized, or to call getOrThrow on an optional instance that is empty. Operations on an empty any will throw a ClassCastException.
OtherInternalException An internal error not represented by another exception type.
ParseException Error that occurs while parsing.
PluginException An exception thrown by an EPL plug-in. Plug-ins may append an addition type to this using a colon (:). For example, Java plug-ins will throw exceptions with the type PluginException:java.class.Name.
StackOverflowException Attempting to use more space than is available on the stack, typically from recursive function calls.
UnmatchedTypeException Thrown by the switch statement if none of the case clauses match the type of the any value and there is no default clause (or the any is an empty value).
Returns:
The type declared when this exception was thrown as a string.

hash

            integer hash()
        
Get an integer hash representation of the underlying object.

This function will return an integer evenly distributed over the whole range suitable for partitioning or indexing of that structure. Multiple different object can resolve to the same hash value.
Returns:
An integer respresentation of the underlying object.

parse

            com.apama.exceptions.Exception static parse(string s)
        
Parse a string as an exception.

The string form of an exception which can be parsed is "com.apama.exceptions.Exception(" MESSAGE "," TYPE ")", where MESSAGE and TYPE are the string forms of the exception type and exception message, including enclosing double quotes.
Parameters:
s - The string to parse.
Returns:
The corresponding Exception object.
Throws:
Throws ParseException if the string cannot be parsed as an exception.
See Also:
com.apama.exceptions.Exception#canParse() - canParse will return false rather than throwing if the string cannot be parsed.

toString

            string toString()
        
Return a string form of the exception.

This form can be parsed with the parse method.
Returns:
The string form of this exception.
See Also:
com.apama.exceptions.Exception#parse() - See the parse method for the string form.

toStringWithStackTrace

            string toStringWithStackTrace()
        
Format this exception and the stack trace.

Use this method for diagnostics on the exception.
Returns:
Returns the exception type, message and also the stack trace from where it was thrown.