I recently had a coding bug where under certain conditions a variable wasn't being initialized and I was getting a NullReferenceException
. This took a while to debug as I had to find the bits of data that would generate this to recreate it the error as the exception doesn't give the variable name.
Obviously I could check every variable before use and throw an informative exception but is there a better (read less coding) way of doing this? Another thought I had was shipping with the pdb
files so that the error information would contain the code line that caused the error. How do other people avoid / handle this problem?
Thanks