|Bookshelf Home | Contents | Index | PDF|
The try statement is used to handle functions that may raise exceptions, which are error conditions that cause the script to branch to a different routine. A try statement generally includes a catch clause or a finally clause, and may include both. The catch clause is used to handle the exception. To raise an exception, use the throw statement (see throw Statement).
When you want to trap potential errors generated by a block of code, place that code in a try statement, and follow the try statement with a catch statement. The catch statement is used to process the exceptions that may occur in the manner you specify in the exception_handling_block.
The finally clause is used for code that should always be executed before exiting the try statement, regardless of whether the catch clause halts the execution of the script. Statements in the finally clause are skipped only if the finally clause redirects the flow of control to another part of the script. The finally statement can be exited by a goto, throw, or return statement.
You can use the try statement to process the exceptions thrown by CORBA objects, and to access their data members and exception names. If the exception contains nested objects or CORBA structures, they are skipped. For more information on creating and using CORBA objects in eScript, read CORBACreateObject() Method.
The following example processes a CORBA exception. It assumes that the user is running the Account server and calling the function clear_balance(-1) on it. This raises the exception
|Siebel eScript Language Reference|