I've run in to code with this pattern:
try
{
// do some potentially bad stuff
}
catch(System.Exception ex)
{
throw ex;
}
I'm not clear as to what the coder had in mind when he caught the exception
only to turn around and rethrow it without doing anything else in the catch
block. Do you know why this would be done? Have you seen this pattern of
try-catch-rethrow before?
I can understand catching the exception, then trying to handle it, and then
throwing another exception if its determined that you can't handle it like
this:
try
{
// do some potentially bad stuff
}
catch(System.Exception ex)
{
if(success == false)
throw new MyNewException;
throw ex;
}
but thats not how it was written. It was simply the first pattern, and I'm
wondering if I'm missing something or does that produce the same effect as
simply not catching the exception in the first place?