Possible Duplicate:
difference between throw and throw new Exception()
I'm a programmer working on adding new functionality to legacy code. While debugging, I parsed over this Catch block, which got an angry "object not set to reference of object" notice from Visual Studio:
catch(Exception ex) { SporeLog.Log("Failed to create new SavedDocumentList with Name: " + name, ex); throw; } What does it mean to "throw". I'm familiar with throw new [exceptiontype]... but what does it mean to just... throw ?
Is this good practice, or should I alter this code to ease the trials of the developers after me?
And why does Visual Studio yell at me for doing this?
throwis not causing theNullReferenceException. As stated below in the answers, thethrowstatement re-throws the exception without resetting the StackTrace. If I understand the nuances of your question, the original exception was a NullReferenceException, which couldn't be handled, so the original coder logged it and rethrew it so it could potentially be handled elsewhere.