You can simply use ArgumentException :
throw new ArgumentException("payload", "'payload' should be...");
As mentioned below, x0r, MSDN recommends only getting an ArgumentException , it may or may not give you added value, it depends on what defines the "invalid" argument passed through the parameter - if you can define strict rules for what can go wrong, then you can benefit from throwing more precisely named exceptions derived from ArgumentException .
Or you can use InvalidDataException with the same informative message if you have one:
An exception that occurs when the data stream is in an invalid format.
Despite accessing the data stream, some objections may arise - let's see.
If this is just a general โbad formatโ exception, then you have a FormatException - but it may be too general for your circumstance (see above), although perhaps this is a much better exception that it really depends on:
The exception that is thrown when the argument format does not match the parameter specifications of the called method.
source share