Topic: Is there a base for built-in exceptions?
Author: clint@vsfl.demon.co.uk (Ian Cameron Smith)
Date: Wed, 2 Feb 1994 18:06:29 +0000 Raw View
I've noticed that C++ will soon be raising exceptions like Bad_cast,
Bad_typeid, and so on (Stroustrap's "Appendix A").
Question: will there a standard base class defined from which
these built-in exceptions will be derived?
I plan to use exception signatures in my code. So a DiskRead
routine would look like:
void DiskRead(Disk &disk, ...) throw(DiskError);
But of course, I have to allow for built-in exceptions, so it
becomes:
void DiskRead(Disk &disk, ...)
throw(DiskError, Bad_cast, Bad_typeid, xalloc, ...);
It and every other routine in my 500k-line project, that is.
Plus, allow for exceptions that the standard C++ library may
soon be defining.
If all of these exceptions were derived from a standard base, like
XStandard, my code would be cleaner:
void DiskRead(Disk &disk, ...) throw(DiskError, XStandard);
I think it would generally make sense for the "standard"
exceptions to be organised in this way, and even for a
"standard" set of exceptions to be defined for use by
libraries. Is this to be the case?
Of course, I could just have a try/catch block in every single
function which converts the built-ins to something common, but
I'm trying to avoid cluttering the code in this way.
--
Ian Cameron Smith clint@vsfl.demon.co.uk
Principal Software Engineer +44 (0)425 474484
Virtual Software Factory LTD
"Go ahead, punk, make my day"