@TheCPUWizard said:
@Sunday Ironfoot said:
@boomzilla said:
....but if you're saying this is a WTF because he could have used the syntactic sugar of using
, then this is more of a mug at best, and pedantic dickweedery to be sure.
No! The WTF is that the try/catch blocks are completely redundant because he's just rethrowing the exceptions up the call stack. I just got sidetracked by the using stuff.
NOT completely redundant since "throw ex" updates the reported stack frame to the current location, and eliminates exposure of the original location. If you want to maintain things then just "throw;"
Also, if there is a possibility the the close in the inner finally will throw,,then the above might be useful [very doubtful, but not impossible]
This has already been covered by someone else. Basically, resetting the stack trace is argubly worse than just having a throw, because you lose information about the origin of the exception.
Also, I'm sure the .NET framework engineers are competant enough to ensure the .Dipose() or .Close() methods won't throw an exception. Indeed it's normal practice to wrap any type that implements IDisposal in a using statement, that's what it's there for.