I am writing a C# client SDK to a REST Api. This SDK sends JSON-serialized models to the API, and implements a first level of verification of the parameters. If the verification fails, it throws an exception.
An example would be:
if (requiredParameter == null)
{
throw new ApiException(400, "Missing required parameter");
}
As you can see, ApiException takes an integer as parameter which represents an HTTP error code (in that context "Bad Request"). I'm not sure HTTP codes are semantically meant to be used when there is no HTTP exchange being done between the client and the server (even though in that context going further would result in a 400 error code being replied by the server).
I would love to have some thoughts on this matter.