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
  Close menu Error Handling
    ASPX Pages
    User Controls
  Open menu Exception Handling
Open menu Customizing the Framework
Globalization / Localization
Open menu General Information
   

Error Handling

The following example uses the Data Provider as an example for illustrating how errors are handled by the foundation classes. These same rules can be applied to other foundation classes. The Data Provider supplies data for the various controller ASPX Pages. When an error occurs, the Data Provider either recovers from the error or it passes the error up to the ASPX Page.

Caution: The Data Provider should never attempt to display the error in any manner. Display of the error message must strictly be handled by the ASPX Page controller.

  • The Data Provider uses the dedicated Foundation Class, FnDPException, to throw exceptions. This class is defined in ..\Program Files\FnOpenClient\Util\FnError.vb.
  • The Data Provider must define the error code name for each error and add it to the FN_ERR_DP enumerator type. The “Fn_ERR_DP_” suffix must be appended to each error code name to allow the error message key to be generated for each error code. The localized error messages must then be added to the resource file.
  • The Data Provider must add code to its helper function to retrieve the localized string. For example:

Public Function DPError(ByVal ErrorCode As Long, ByVal e As Exception) As FnDPException
   Dim msg As String
   Dim aDPExcep as FnDPException

   Select Case ErrorCode
      Case FN_ERR_DP.FailedToGetStepElement
         msg = rm.GetResourceString("FN_ERR_DP_ FailedToGetStepElement")
      Case FN_ERR_DP.NoPrefetchedStepElement
         msg = rm.GetResourceString("FN_ERR_DP_NoPrefetchedStepElement")...
      Case Else
         msg = rm.GetResourceString("FN_ERR_UnknownError")
   End Select

   If e Is Nothing Then
      aDPExcep = New FnDPException(msg)
   Else
      aDPExcep = New FnDPException(msg, e)
   End If
   aDPExcep.FnErrorCode = ErrorCode
   Return aDPExcep
End Function

Public Function DPError(ByVal ErrorCode As Long) As FnDPException
   Return DPError(ErrorCode, Nothing)
End Function

  • The Data Provider must always use the helper function to throw an FnDPException. For example:

    Dim aErrObj as new FnUtil.FnError()
    Throw aErrObj.DPError(FN_ERR_DP.FailedToGetStepElement, Nothing))

  • The Data Provider layer must directly interface with underlying COM objects. The Data Provider can wrap or replace the original exception with a localized error message. (For example, FileNet IDM COM objects only support one localized resource.) The Data Provider can catch specific COM exceptions using the syntax outlined in Handling IDM ComException.