A number, character or string literal is thrown instead of an exception object
What it finds
throw 42; or throw "failed"; throws a value that handlers for std::exception do not catch and that carries no type to dispatch on. An exception class, such as std::runtime_error, holds the message and fits the usual handlers.
From the rule's source, throw_literal.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:
[rules]
"tx0/cpp:throw-literal" = "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:throw-literal] reason="..."tx0 explain tx0/cpp:throw-literal shows the same in the terminal. Found a false positive? Report it.