CSharp - Exception Exception filters

Introduction

You can create an exception filter in a catch clause using when clause:

catch (ConnectionException ex) when (ex.Status == ConnectionExceptionStatus.Timeout)
{

}

If a ConnectionException is thrown, the Boolean expression following the when keyword is evaluated.

If the result is false, the catch block in question is ignored, and any subsequent catch clauses are considered.

With exception filters, you can catch the same exception type again:

catch (ConnectionException ex) when (ex.Status == ConnectionExceptionStatus.Timeout)
{}
catch (ConnectionException ex) when (ex.Status == ConnectionExceptionStatus.SendFailure)
{}