concept exception filter in category c#
appears as: Exception filters, n exception filter, exception filter

This is an excerpt from Manning's book C# in Depth, Fourth Edition.
With an exception filter, if you don’t want to handle an exception, you don’t catch it; you filter it away from your catch block to start with:
try { ... #1 } catch (WebException e) when (e.Status == WebExceptionStatus.ConnectFailure) #2 { ... #3 }Beyond specific cases like this, I can see exception filters being useful in two generic use cases: retry and logging. In a retry loop, you typically want to catch the exception only if you’re going to retry the operation (if it meets certain criteria and you haven’t run out of attempts); in a logging scenario, you may never want to catch the exception but log it while it’s in-flight, so to speak. Before going into more details of the concrete use cases, let’s see what the feature looks like in code and how it behaves.