Apex InvalidParameterValueException class constructor parameters?
It's Java, not Apex, but here is some documentation on a version of InvalidParameterValueException
which suggests the first argument is the name of the parameter, and the second is its value:
Field Summary
Fields
|============================================================| | Modifier and Type | Field and Description | |==============================|=============================| | static java.lang.String | PARAM_NAME | | | The default value of | | | the parameter name. | |------------------------------------------------------------| | static java.lang.String | PARAM_VAL | | | The default value of | | | the parameter value. | |============================================================|
I use the first param as the name of the method being called and the second for the parameter value that's invalid. In other languages that's super useful for debug purposes. However, if you do a System.debug(e);
in your code you'll notice it just prints Script-thrown exception. So I'm not sure how helpful the two parameters really are here. I always add an additional line as well:
ex.setMessage('ABC is not valid for XYZ');
to help with actual debugging.
But I still use method name & variable value out of habit (and the hope that in later versions the toString will be overridden to be more useful).