CSharp examples for Custom Type:try catch finally
You can specify an exception filter in a catch clause by adding a when clause:
catch (WebException ex) when (ex.Status == WebExceptionStatus.Timeout)
{
...
}
With exception filters, it can be meaningful to catch the same exception type again:
catch (WebException ex) when (ex.Status == WebExceptionStatus.Timeout) { ... } catch (WebException ex) when (ex.Status == WebExceptionStatus.SendFailure) { ... }