API exceptions - codes or hierarchy, or both?

The DDR API will require support for exceptions. Early drafts suggest two approaches to representing exceptions:
 
1. Each exception is represented by a unique constant (e.g. short int). This constant may be contained in a generic exception class and interpreted by a generic exception handler.
 
2. There's a base class for exceptions, and a hierarchy of more refined exception classes, each containing member attributes particular to the exceptions being thrown.
 
A third possibility is a hybrid of the two.
 
3. Each exception has a code defined in the API specification, but the exception classes are also in a hierarchy. The handler may then recognise an exception either by its code, or by the class type associated with the exception.
 
Given the broad spectrum of target languages, I am inclined to consider the most flexible representation, so the third option is appealing. What do others think?
 
---Rotan.

Received on Tuesday, 24 July 2007 09:50:29 UTC