Working on existing code, I recently found smt like this:
if(Config.ExceptionBehavior.DEBUG_EXCEPTIONS)
{
foo.Foo();
}
else
{
try
{
foo.Foo();
}
catch(Exception ex)
{
//whatever
}
}
I am getting rid of this - but I do see some value in the driver of this kind of code: basically the guy who wrote this wanted the thing to crash on the line the exception occurred for debug purpose. At the same time this smells awfully, because you're replicating your code arbitrarily, which makes everything quite messy and littered.
Is there any decent why of obtaining similar behavior without shamelessly littering your code?
The only alternative I can think of is a bunch of #if DEBUG
etc. but wondering if there is any app wide exception handling lib that can give me something like this.
Any pointers appreciated!