Developing Apama Applications > EPL Reference > Statements > Compound statements > The try-catch statement
The try-catch statement
The try-catch statement is used to handle runtime exceptions.
The catch clause must specify a variable whose type is com.apama.exceptions.Exception.
You can nest try-catch statements in an action, and you can specify multiple actions in a try block and specify a try-catch statement in any number of actions.
See also Catching exceptions.
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;
}
}
Copyright © 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.