Developing Apama Applications > Apama EPL Reference > Statements > Compound statements > The try-catch statement
The try-catch statement
The try-catch statement is used to handle runtime exceptions.
TryCatchStatement
Rule components
The catch clause must specify a variable whose data 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 in Developing Apama Applications in EPL.
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 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.