/****************************************************************************/ /* */ /* ZMexception implementation justification */ /* */ /****************************************************************************/ Summary: The actual design documentation for the ZMexception class can be found in the "ZOOM Excetion mechanism design document" When try to explain why we chose the implementation we are using. Background: The exception mechanism design calls for keeping track of information for each class of exception. For example being able to set the handler that will be user for all the instance of a particular exceptions class. In addition each exception class must know how to contact its parent class so that if no handler or no logger have been set for a class, it can refer to its parent's. One way to implement to scheme would have been to have an exception factory that would act as a repository of all informations. Two problems exist with this solution. First the 'factory' somehow need to be told about each new exception class (that might be solved if we had template member functions). Second the syntax for throw a zoom exception will send be further for the 'normal' syntax. It would probably have to be something like : ZMthrow(ExceptionFactory.ZMxTheExceptionIthrow(....)) Another way of implementing class wide information is to use static data member and functions. A short example of the type interface wanted is: class TopException : xxxxx { static Handler* getHandler() static setHandler(Handler*) static Handler* _handler }; class BottomException : TopException { static Handler* getHandler() static setHandler(Handler*) static Handler* _handler }; Explanation: This look like a prime candidate for a template implementation. One way to do so would be: template class Exception : public Parent { static Handler* getHandler() static setHandler(Handler*) static Handler* _handler }; However you have then no way to have two 'children' from the same parent ( all 'child' will have the same name: Exception ). Another solution would be: template class Exception : public Parent { Exception(string message); static Handler* getHandler() static setHandler(Handler*) static Handler* _handler }; class Current: public Exception { } But this scheme limit the flexibility you have in creating new exception classes. For example the constructor need to look like: template Exception::Exception(string) : Parent(string) { } I.e the template need to assume the existence of one particular constructor for the "Parent" and stick to it. Hence if the meaningfull constructor for Current is Current(string message, Column* c), no Child of Current will be actually be calling this constructor. The child of current would be: class Child : public Exception { Child(string,Col*) : Exception(msg) {}; } Note that child can not be calling directly the constructor a current and thus is restricted to call the only constructor of Exception ! A solution around this problem would be to always provide a constructor without any parameters and to do the initialization in an init function with the correct parameters (and there Child could directly call Current's init function)