4
I searched the Internet and I still haven’t found an answer mature enough for a problem.
I have an Ajax request and taking out errors released by the application as a possible connection drop, for example, I don’t want to throw an exception if I have a business error.
For example, the user enters an invalid email address in the email field. I want to throw an error, but not as a request error so that the object error function jQuery ajax treat it. I don’t want something like 400 and 500 range HTTP errors.
I want to return status 200 as the request was successful, but somehow identify that there was a business error.
I see a lot of people returning an object JSON with a successful/failed Boolean attribute and if this same object is failed it has another Jsonarray object with the error messages.
This would be the best way to really drive when there is a business error and not infrastructure or application itself?
The status code 400 is precisely to represent a customer error. If the customer sends a poorly formatted email then it is a customer error. Conceptually, it is wrong to treat as a success a request that did not meet the necessary prerequisites and had to be aborted. Conceptually you do not have a "success". Now if Voce has some limitation and can not implement the answer code 400 there is another story.
– Renato Gama
Type 400 errors cover business error? A user who sends an invalid URL, or a string instead of a numeric field, and so on? These errors should be treated by the range 400?
– Philippe Gioseffi
See my answer below
– Renato Gama