next up previous contents index
Next: 4.4 Binary Issues Up: 4 The Component Object Previous: 4.2 Reference and Memory

4.3 Error Handling

 

The COM specification defines a standard 32-bit namespace for error codes, which the OSKit adopts as the error code namespace for all of its exported interfaces, both COM and conventional. COM error return values are divided into three fields: a one-bit severity flag, indicating success (zero) or failure (one), a 15-bit facility, providing a broad categorization of error, and finally, a 16-bit code, which indicates the specific error and is only meaningful with respect to a particular facility.

Unfortunately, the management of error codes is one of the relatively few parts of COM in which Microsoft-centrism appears in force. Ideally, error codes should be GUIDs, just like interface identifiers; however, this would be too cumbersome and inefficient in practice. Therefore, COM divides the error code namespace into two categories: globally-unique, centrally allocated error codes, and interface-specific error codes. Most interfaces are expected to use the interface-specific range; these error codes are only meaningful when returned from methods on a particular COM interface, and their meanings are defined as part of that COM interface. However, as may be expected, most of Microsoft's COM interfaces use centrally administrated error codes since they are much easier to deal with in large software systems and, conveniently, Microsoft happens to be the ``central administrative authority.'' Furthermore, again as may be expected, Microsoft does not readily allocate facility codes to third parties.

The OSKit defines a number of error codes that need to be valid across a large number of interfaces, both COM and non-COM; it would be difficult or impossible to make these error codes fit into the ``interface-specific'' paradigm. Further, since only one small 64K range has been assigned for interface-specific error codes, out of the two billion possible values, we felt that using values in the interface-specific range to represent errors that are treated as globally unique by OSKit components would be just asking for trouble in the long term, since in such a small namespace collisions are inevitable. Therefore, for global error codes used by the OSKit, we have informally allocated (i.e., stolen) facility code 0xf10 for our purposes. For the specific assignment of error codes in this range, see the description of oskit/error.h, in Section 4.6.2. However, the OSKit still uses the interface-specific error code range, when appropriate, for error codes only meaningful to a particular interface.


next up previous contents index
Next: 4.4 Binary Issues Up: 4 The Component Object Previous: 4.2 Reference and Memory

University of Utah Flux Research Group