Recently, I had a chance to review error handling of a package and I found many error checking lines are throwing
ArgumentError but in various reasons. Some lines are complaining about a argument value, some lines are about argument types, some lines are saying even an argument is not supported yet.
However, when I check the help document about
ArgumentError, I can see:
The parameters to a function call do not match a valid signature. Argument msg is a descriptive error string.
So, the document is saying you can throw the exception in a case of mismatched signature. Wait! How can the method be called if its signature is not matched? In fact, none of the code lines I saw threw the exception for the purpose.
I have a feeling that
ArgumentError has been abused so far without clear instructions. If you are a Julia expert, would you tell me exactly when the exception should be thrown? Also appreciate if somebody updates the help document with more details.