On Mon, Sep 10, 2007 at 01:21:15PM -0500, Bo Peng wrote:
> > Which reminds me of another yet-unstarted battle: Do we really want
> > hard crashs as the prefered way to tell the user that there is something
> > wrong in Denmark?
> 
> I have long thought of this. Many internal errors does not really
> prevent lyx from functioning, but lyx simply crashes without even a
> proper error message.  For example, if a cursor can not be placed
> correctly, or if undo fails, lyx should continue to work.
> 
> I think this is a consequence of lyx' refusal to use try/catch
> exceptions in the past, and is something that should be addressed.

It's an ivory tower thing along the lines of "we know that something
might have gone wrong, and to piss off the user too, take the most
painful way out and crash". Even if we just discovered that we can't show
a note in the favoured shade of yellow and pink would have been an
acceptable alternative. Likewise for lfuns. "Hey, I can't go further to
the right. Maybe that's just the end of the document, but I prefer to
play confused and crash".

> To be dramatic, all BOOST_ASSERT should be ignored in the release mode...

No... we should have some 

  LYX_ASSERT(condition, what_to_do_if_condition_failed)

Just doing nothing is usually not suitable, even in release mode.

Something like 

#ifndef LYX_DEBUG_MESSAGE
#       ifdef DEBUG
#               define LYX_DEBUG_MESSAGE(what) showMessage(what);
#       else
#               define LYX_DEBUG_MESSAGE(what) /*nothing?*/
#       endif
#endif

#define LYX_ASSERT(condition, reaction) \
        do { \
                if (condition) ; else { \
                        LYX_DEBUG_MESSAGE("Condition" #condition " failed!") \
                        reaction; \
                } \
        } while (0)

would be close to what I'd sonsider useful.

Whoever wants to get his daily dose of pain could define
LYX_DEBUG_MESSAGE to "{int i = *(int*)0; }" or similar to get the
current behaviour.

Andre'

Reply via email to