From: Ed Musgrove <edgarmusgrove@wa...> - 2009-12-30 01:08:22
Many of the switch statements have no default case. When I am proposing a
patch to a function with such a statement should I add something like:
wxMessageBox(wxT("appropriate error statement" ));
From: Richard Ash <richard@au...> - 2010-01-02 15:45:02
On Tue, 2009-12-29 at 16:08 -0800, Ed Musgrove wrote:
> Many of the switch statements have no default case. When I am proposing a
> patch to a function with such a statement should I add something like:
> #ifdef DEBUG
> wxMessageBox(wxT("appropriate error statement" ));
Yes, you should consider adding a default case to switch statements
which don't have one, but not one that does that. What the correct
action is depends a bit on the context, and specifically whether there
is an obvious default action (so the code can continue), or whether the
error is sufficiently fatal that the code needs to be aborted.
If there is a sensible default, then using wxLogDebug for the error
message is the right solution. This will send the log message to the
audacity debug log (which you can access from the Help menu), but not
get in the user's way.
If there is no sensible solution and we need to abort the code, then use
WXASSERT_MSG() to do so - this will stop the program, and if it is
running in a debugger, show exactly where the code came to a halt, which
makes working out why easier.
Both of these macros evaluate to no-ops in release builds, so make sure
that the behaviour when the code falls through them is sensible and
doesn't lead to further strange behaviour.
Get latest updates about Open Source Projects, Conferences and News.