Apama 10.15.0 | Release Notes | What's New in Apama 5.1 | New EPL exception handling mechanism
 
New EPL exception handling mechanism
EPL now supports the try ... catch exception handling structure for processing runtime errors. The statements in each block must be enclosed in curly braces. For example:
using com.apama.exceptions.Exception;
...
action getExchangeRate(
dictionary<string, string> prices, string fxPair) returns float {
try {
return float.parse(prices[fxPair]);
} catch(Exception e) {
return 1.0;
}
}
An exception that occurs in try block1 causes execution of catch block2. Two new types have been added to support exception handling:
*com.apama.exceptions.Exception — A variable of this type contains an exception message and an exception type. It also contains a sequence of com.apama.exceptions.StackTrackElement objects. The sequence represents the stack trace for when the exception was first thrown. Exception objects have methods for accessing the exception message, the exception type, and the stack trace.
*com.apama.exceptions.StackTraceElement — A variable of this type contains information for one stack trace entry. A StackTraceElement object has methods for accessing the details for the stack trace entry it represents.
try, catch and throw are now keywords. If you want to use one of these words as an identifier you must prefix it with a hash symbol (#), otherwise it is an error.
For details, see Exception handling.