Re: [Alephmodular-devel] Enum versus class?
Status: Pre-Alpha
Brought to you by:
brefin
|
From: Dietrich E. <die...@zd...> - 2003-03-02 08:58:50
|
On Saturday, Mar 1, 2003, at 23:59 US/Pacific, Br'fin wrote:
[...]
> Exceptions I'm still mulling over in my head. I'm used to Java's
> exception mechanism, and still need to learn C++'s approach. The first
> thing you're apt to see on that front is a try/catch block in main and
> a growing use of exceptions first thrown from fatal csaslert dialogs
> and asserts and in place of halt().
[...]
Yah... the hardest part, adding error checking. You could break it
down into parts, and add exception handling to each part individually,
marking the bits that are error-proof (well, nothing is error-proof,
but things like the really low-level rasterizing code can essentially
be guaranteed not to cause an exception).
What I have found helpful in the past is to make a macro for creating
exceptions, like
class _Exception { ... };
#define Exception(parms...) _Exception (__FILE__, __LINE__,
__PRETTY_FUNCTION__, parms)
or some variant. The things that compilers other than GCC would choke
on could be cut out (methinks __PRETTY_FUNCTION__ is gcc) with #ifdefs.
|