The most important thing for a client is to check FAILED for any error return. Other than that, (the statements above not withstanding) a robust, user friendly client should assume that the server may return any error code and should call the GetErrorString function to provide user readable information about those errors.
Standard COM errors that are commonly used by OPC Servers | Description |
E_FAIL | Unspecified error |
E_INVALIDARG | The value of one or more parameters was not valid. This is generally used in place of a more specific error where it is expected that problems are unlikely or will be easy to identify (for example when there is only one parameter). |
E_NOINTERFACE | No such interface supported |
E_NOTIMPL | Not implemented |
E_OUTOFMEMORY | Not enough memory to complete the requested operation. This can happen any time the server needs to allocate memory to complete the requested operation. |
CONNECT_E_ADVISELIMIT | Advise limit exceeded for this object |
OLE_E_NOCONNECTION | Cannot Unadvise - there is no existing connection |
DV_E_FORMATETC | Invalid or unregistered Format specified in FORMATETC |
OPC Specific Errors | Description |
OPC_E_BADRIGHTS | The Items AccessRights do not allow the operation. |
OPC_E_BADTYPE | The server cannot convert the data between the specified format/ requested data type and the canonical data type. |
OPC_E_DUPLICATENAME | Duplicate name not allowed. |
OPC_E_INVALIDCONFIGFILE | The server's configuration file is an invalid format. |
OPC_E_INVALIDFILTER | The filter string was not valid |
OPC_E_INVALIDHANDLE | The value of the handle is invalid. Note: a client should never pass an invalid handle to a server. If this error occurs, it is due to a programming error in the client or possibly in the server. |
OPC_E_INVALIDITEMID | The item ID doesn't conform to the server's syntax. |
OPC_E_INVALID_PID | The passed property ID is not valid for the item. |
OPC_E_NOTFOUND | Requested Object (e.g. a public group) was not found. |
OPC_E_PUBLIC | The requested operation cannot be done on a public group. |
OPC_E_RANGE | The value was out of range. |
OPC_E_UNKNOWNITEMID | The item ID is not defined in the server address space (on add or validate) or no longer exists in the server address space (for read or write). |
OPC_E_UNKNOWNPATH | The item's access path is not known to the server. |
OPC_S_CLAMP | A value passed to WRITE was accepted but the output was clamped. |
OPC_S_INUSE | The operation cannot be performed because the object is bering referenced. |
OPC_S_UNSUPPORTEDRATE | The server does not support the requested data rate but will use the closest available rate. |
You will see in the appendix that these error codes use ITF_FACILITY. This means that they are context specific (i.e. OPC specific). The calling application should check first with the server providing the error (i.e. call GetErrorString).
Error codes (the low order word of the HRESULT) from 0000 to 0200 are reserved for Microsoft use (although some were inadverdantly used for OPC 1.0 errors). Codes from 0200 through 7FFF are reserved for future OPC use. Codes from 8000 through FFFF can be vendor specific.