Hello! Please help me find a solution.
I have a simple RestController that accepts data in a POST request, processes it and sends the response to the client application (as a collection). How to return an http response with error codes 404, 403, etc., if, for example, an empty collection is returned after processing?
I mean, if an exception occurred in the controller's method during data processing, is it possible to return a response containing the error status? So that the error code is indicated by me? Maybe someone will tell you where to find an example or literature on this?
It seemed to me that something related to @ExceptionHandler could help, but I can’t find an explanation for it. Here is the book Manning would be very helpful if there was on this issue ...