Saturday, July 9, 2011

You “Try”… and what do you “Catch”… A TryCatchException!

This is posted without much ranting, hoping that the humour and the pun is evident and the code snippet self-explanatory. This code was written by someone who apparently regarded the try{} catch {} construct itself error prone and decided to catch a TryCatchException.

try
{
    //Some Magic Code here
}
catch (Exception ex)
{
    var exceptionEntry = new TryCatchException("Method error", ex);
    throw exceptionEntry;
}

I have to admit this one is an original. I particularly like the additional detail (that is completely useless) “Method error”


Code Responsibly.