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
   

Handling ComException

The FileNet COMException is thrown when an unrecognized HRESULT is returned from a COM method call. The HRESULT field contains the HRESULT returned by the calling function. The actual error code can be accessed from exp.errorcode or Err.Number. To filter out a specific exception thrown by an IDM object, use a mechanism similar to the following:

Imports System.Runtime.InteropServices
Try
...
Catch exp as COMException
   'The value is too long for the property field.
   If Err.Number = IDM_COM_ERR.DictValueOutOfRange Then
      'DictValueOutOfRange is 0x80041E1B
      'Throw a localized error message or something similar
      Dim aErrObj as new FnUtil.FnError()
      Throw aErrObj.COMError(IDM_COM_ERR.DictValueOutOfRange, strLibName)
   Else
      ...
   End If
End Try

The above sample is usually implemented in a Data Provider where IDM objects are heavily used. Developers are recommended to place the COMException error handler in a central location within the application, to enable conversion and localization of the IDM exceptions. Define your own error enumerator for each specific IDM exception that you want to handle.

The following enumerator type is used to map the IDM error code (HRESULT):

Public Enum IDM_COM_ERR
   InvalidCredential = &H8004162B
   CSInvalidCredential = &H8004FA02
   LDAPAuthenticationFailed = &H80046A03
   LDAPInvalidCredential = &H80046A07
   LDAPPasswdExpired = &H80046A0A
   LDAPNULLPassword = &H80046A0D
   LDAPNULLUserName = &H80046A0E
   DictValueOutOfRange = &H80041E1B
End Enum