Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V741. Use of the throw (a, b);...
menu mobile close menu
Additional information
toggle menu Contents

V741. Use of the throw (a, b); pattern. It is possible that type name was omitted: throw MyException(a, b);.

Jan 19 2016

The analyzer detected the throw keyword followed by a pair of parentheses with various values inside separated by commas. It is very likely that the programmer forgot to specify the type of the exception to be thrown.

Consider the following example:

throw ("foo", 123);

Although the code looks strange, it compiles successfully. In this case, executing the comma operator ',' results in the value 123. Therefore, an exception of type 'int' will be thrown.

In other words, the code above is equivalent to the following:

throw 123;

Correct code:

throw MyException("foo", 123);

This diagnostic is classified as: