Any RPC command called with the wrong number of arguments currently raise a std::runtime_error exception which is then mapped to a RPC_MISC_ERROR when executed from a CRPCTable.
This error code doesn’t bring any value and should only be used when no other error codes make sense.
However in this case, it could easily fall into RPC_INVALID_REQUEST case or maybe RPC_INVALID_PARAMETER?
...just found out that, for example, Ethereum choose to map this to RPC_INVALID_PARAMETER:
https://github.com/ethereum/go-ethereum/blob/master/rpc/errors.go#L47-L52
The current RPC http implementation would internally map
RPC_INVALID_REQUESTto a400http code whereasRPC_INVALID_PARAMETERwould still be mapped to a500as it previously was with theRPC_MISC_ERRORcode.
Furthermore, the current implementation also handle the help command by throwing and then catching a std::exception in std::string CRPCTable::help. The flaw in this implementation is that any JSONRPCError thrown are just ignored, because JSONRPCError isn’t an Exception.
For example in the case of getinfo, which is deprecated, a call to help getinfo would lead to an error whereas the help command is just doing its job.
By switching to a JSONRPCError this proposition would catch each std::exception and JSONRPCError when executing the help command. This preserve the main help command behaviour: to present the usage/help to the user without any error code. A test case has been added to ensure every help can be reached without throwing an error.
A step ahead would be to remove the help command dependence to the error handling process. Each commands could just return the help message when called from the help command.