On Mon, 28 Apr 2008 13:16:19 +0200, <J.B.C.Engelen@...1578...> wrote:
However, I think it is best if we add some sort of debug
flag so that
people can choose between throwing an exception or doing an assert (crash).
Do you mean a simple #ifdef DEBUG or an ad-hoc flag ? Something like ELLIPTICAL_ARC_DEBUG ?
I meant a global flag, that chooses how to expand the exception throw macros; not just for the elliptical arc implementation. So 2geom either throws exceptions or does asserts.
#define LIB2GEOM_EXCEPTIONS // define to have 2geom throw exceptions instead of asserts
That's ok, however I was thinking that it would be better to have the conditional defined code in just one place. So what do you think of defining the throwXxxxYyyy macros in the following way:
#ifdef LIB2GEOM_EXCEPTIONS # define throwException( cond, message ) \ if ( (cond) ) throw(Geom::Exception(message, __FILE__, __LINE__)) # define throwRangeError( cond, message ) \ if ( (cond) ) throw(RangeError(message, __FILE__, __LINE__)) . . . #else # define throwException( cond, message ) \ if( (cond) ) std::cerr << "lib2geom Error: " << message << std::endl; \ assert( (cond) ) # define throwRangeError( cond, message ) \ if( (cond) ) std::cerr << "lib2geom RangeError: " << message << std::endl; \ assert( (cond) ) . . . #endif // LIB2GEOM_EXCEPTIONS
Marco