> Could you please post a use case or two where you think exceptions
> will improve LyX significantly?

When I get my hands dirty with output_latex, paragraphlist, cursor
etc, lyx will simply crash for a misuse of function, and leave me no
clue what goes wrong. I would vote for much more assert and throw in
the code. Attached is something I use in my own project:

#ifndef OPTIMIZED

#define DBG_ASSERT(cond, exception, message) \
if(!(cond)) \
{ \
  throw exception( \
  toStr(__FILE__)+toStr(":")+toStr(__LINE__)+toStr(" ")+message); \
}

#define DBG_FAILIF(cond, exception, message) \
if(cond) \
{ \
  throw exception( \
  toStr(__FILE__)+toStr(":")+toStr(__LINE__)+toStr(" ")+message); \
}

#define DBG_WARNING(cond, message) \
if(cond) \
{ \
  cout << "Warning (line " << __LINE__ << " in " << __FILE__ << "): "
<< message << endl; \
}

#else                                           // optimized mode

#define DBG_ASSERT(cond, exception, message)
#define DBG_FAILIF(cond, exception, message)
#define DBG_WARNING(cond, message)

#endif

I have a lot of DBG_ASSERT in my code and if anything goes wrong, I
have the exact line number of where my program fails.

Cheers,
Bo

Reply via email to