Of course you could always add an exception handler:
void Try(Action a, Action<Exception> onErr)
{
try
{
a();
}
catch (Exception e)
{
onErr(e);
}
}
Then you'd have:
Try(
()=> { /* do something */ }
e => { } );
You could have a standard empty hander
static void IgnoreError(Exception e)
{
#if DEBUG
throw e;
#end if
}
Try(
()=> { /* do something */ }
IgnoreError );
I don't think that's bad as such, but it is very non-standard - your code will be confusing and I don't think it adds anything. It's interesting to consider, but I think your code will end up very confusing.
Also, while there are circumstances where you might want to ignore an exception you don't really want to make it easier to do so regularly.