Exception Filters
suggest changeSince C# 6.0, exceptions can be filtered with a when clause.
This is similar to a simple if inside the catch, but if the when condition is false the stack is not unwound and the exception can still be caught by an outer handler.
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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents