[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ppThrow () flaws



Christian Reiniger writes:
 > Hi,
 > 
 > I just noticed that ppThrow () has a relatively serious flaw. 
 > 
 > Example code:
 > ------------
 > 
 > obscuretype somefunction (something XY)
 > {
 > 	if (correct == false)
 > 		ppThrow (ppEObscureFailure, "It is wrong");
 > 	
 > 	ResumeNormalWork ();
 > }
 > ---------------
 > 
 > This works fine as long as ppThrow is evaluated. But if it's not,
 > ResumeNormalWork () is called even if (correct == false). That's wrong.
 > "ppThrow (..)" has to be replaced by "return errorindicator" in that case.
 > 
 > Any ideas on how to implement this in an elegant way?

Yes, don't.

 * * Exceptions used for debugging. Those should only be caught by some
 *   toplevel error message dumper, exiting the app. Those should include as
 *   much info as possible, including __LINE__ etc, but they also have to be
 *   used only while debugging. Use the ppThrow (description) macro for this.
 *

If when debbging is on these are only supposed to be caught by some
top level message dumper, then without debugging, the program should
just crash and burn if ppThrow is called.  One thing I don't
understand is, if ppThrow style exceptions should only be caught at
top level, then how is that different from calling some function
which spits an error message and aborts?  (ppgInternalError I think).