I have a class hierarchy, and each class in it has an exception class, derived in a parallel hierarchy, thus...
class Base
{
};
class Derived : public Base
{
};
No, it's not reasonable as it stands right now. For the derived type to have any meaning (from the point of view of Liskov's substitution principle), there needs to be polymorphic behavior in the base class.
You could add a virtual int GetError() const
to the base class and let the derived classes override it, but then a user of a BaseException*
or BaseException&
wouldn't have any clue as to what the error code returned by the derived classes meant.
I'd separate the error code values from the classes.