Skip to content

Instantly share code, notes, and snippets.

@jchannon
Created April 2, 2012 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchannon/2282494 to your computer and use it in GitHub Desktop.
Save jchannon/2282494 to your computer and use it in GitHub Desktop.
public void DoSomething(string Data)
{
int localVar = int.Parse(Data.ToString)); //BOOM! Exception
}
//I need to make sure I handle this otherwise users aren't going to be happy
public void DoSomething(string Data)
{
try
{
int localVar = int.Parse(Data.ToString)); //BOOM! Exception
}
catch(NullReferenceException ex)
{
//Catch it and notify user
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment