Skip to content

Instantly share code, notes, and snippets.

@ThomasArdal
Last active August 29, 2015 14:06
Show Gist options
  • Save ThomasArdal/4a19066f72f966983f43 to your computer and use it in GitHub Desktop.
Save ThomasArdal/4a19066f72f966983f43 to your computer and use it in GitHub Desktop.
Try catch with exception filters
try
{
DoSomeHttpRequest();
}
catch (System.Web.HttpException e) if (e.GetHttpCode() == 400)
{
WriteLine("Not Found");
}
catch (System.Web.HttpException e) if (e.GetHttpCode() == 500)
{
WriteLine("Internal Server Error");
}
catch
{
WriteLine("Generic Error");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment