CodeQL library for C#
codeql/csharp-all 1.0.1 (changelog, source)
Search

Class ExceptionHandlerSplitting::ExceptionHandlerSplit

A split for elements belonging to a catch clause, which determines the type of exception to handle. For example, in

try
{
    if (M() > 0)
        throw new ArgumentException();
    else if (M() < 0)
        throw new ArithmeticException("negative");
    else
        return;
}
catch (ArgumentException e)
{
    Log.Write("M() positive");
}
catch (ArithmeticException e) when (e.Message != null)
{
    Log.Write($"M() {e.Message}");
}

all control flow nodes in

catch (ArgumentException e)

and

catch (ArithmeticException e) when (e.Message != null)

have two splits: one representing the try block throwing an ArgumentException, and one representing the try block throwing an ArithmeticException.

Import path

import semmle.code.csharp.controlflow.internal.Splitting

Direct supertypes

Indirect supertypes

Predicates

getExceptionClass

Gets the exception type that this split represents.

toString

Gets a textual representation of this split.

Charpred