Reputation: 9506
Is there any reason to avoid to send logical error as an HTTP 500 error? I'm developing a web-app, after an Ajax call I have the default error handler that shows a modal notice with the text of the error.
In some case the error can be logical ('ID not found' or 'The input is not a number' ...), in these cases can I send a HTTP error or it should be reserved only for trasportation/authentication error?
Upvotes: 0
Views: 126
Reputation: 42915
This certainly is possible from a technical point of view, but I would advise against it. Reason is that you confuse a logical error in the request and a processing error in the processing. Those should be kept separate.
Instead I suggest you use http code 406 Not Acceptable
. It signals that the request has been received, but will not be processed because "it does not make sense". I'd say that is more suitable.
Upvotes: 1