Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sowamazing/ea39c102be4fd703393cb0f2f532c551 to your computer and use it in GitHub Desktop.
Save sowamazing/ea39c102be4fd703393cb0f2f532c551 to your computer and use it in GitHub Desktop.
try
{
// Your code that might throw an error
}
catch( ExceptionName e )
{
// What you want to do when the error is thrown
}
For instance, suppose we accidentally divide by zero. Our code would look like the following:
try
{
int x = 1/0;
}
catch(DivideByZeroException e )
{
// What you want to do when the error is thrown
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment