An exception of a class type is caught by value, which copies it and cuts off the parts of derived classes

tx0/cpp:catch-by-valuerecommendedwarningreliability/error-handlingdepth fastbug

What it finds

catch (std::exception e) copies the exception into e; an exception of a derived class is sliced to its base, so e.what() and virtual calls see the base only. Catching by reference, catch (const std::exception &e), keeps the object as thrown.

From the rule's source, catch_by_value.rs.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/cpp:catch-by-value" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/cpp:catch-by-value] reason="..."

tx0 explain tx0/cpp:catch-by-value shows the same in the terminal. Found a false positive? Report it.