I searched the internet and still did not find a mature enough answer to a problem.
I have an Ajax request and taking errors thrown by the application as a possible connection crash, for example, I do not want to throw an exception if I have a business error.
For example, the user enters an invalid address in the email field. I want to throw an error, but not as request error so that the error function of the jQuery ajax object will deal . I do not want something like HTTP errors of the 400 and 500 ranges.
I want to return status 200, because the request was successful, but somehow identify that there was a business error.
I see a lot of people returning a JSON object with a boolean attribute of success / failure and if it fails this same object has a another JSONArray object with the error messages.
Is this the best way to really drive when there is a business error, not the infrastructure or the application itself?