Since C# 6.0 exceptions can be filtered using the when
operator.
This is similar to using a simple if
but does not unwind the stack if the condition inside the when
is not met.
Example
try
{
// ...
}
catch (Exception e) when (e.InnerException != null) // Any condition can go in here.
{
// ...
}
The same info can be found in the C# 6.0 Features here: Exception filters