Skip navigation FileNet logo
  Open Client Developer's Guide
  Search  |  Index  |  Glossary   |  
Open menu Overview
Open menu Open Client Architecture
Open menu Developing for Process
Close menu Error and Exception Handling
  Open menu Error Handling
  Close menu Exception Handling
    Defining a New Exception
    Error Helper Functions
    Handling Guidelines
    Handling COMException
    Logging Exceptions
Open menu Customizing the Framework
Globalization / Localization
Open menu General Information
   

Exception Handling

Developers are encouraged to implement try...catch…finally blocks to handle error exceptions in their Web applications. A try...catch block consists of a statement that attempts to execute something that might cause an exception to occur. When an exception does occur, execution control is immediately passed to the catch block, which then deals with the exception. If an exception does not occur, then the application code executes normally.

Try
   If aSrchObj.GetState(idmStoredSearchStateSelector.idmStoredSearchIsTemplate) Then
      SrchCtrl.Open(srchObj)
   Else
      aSrchCtrl.RemoveControls()
      Execute_SS(srchObj)
   End If
Catch exp As Exception
   anErrObj.HandleException(exp)
Finally
   aSrchObj = Nothing
End Try

When throwing an exception, developers should clean up the intermediate results. This enables calling functions to assume that there will be no side effects when an exception is thrown. A finally block can also be added after the catch block, to contain code segments that will execute whether or not any exceptions are raised.

Catch blocks are tried in the order in which they are declared within the try...catch statement. When using multiple catch blocks, developers should put the finest-grained exception first and the base (most general) exception last.

Caution: If a catch block is left empty, exceptions that occur in the try block will never be handled and lost forever. Catch blocks should never be left empty.