I advice you not to handle errors API by API. You should throw a known exception in your system with the message, parameters and any piece of information you will judge useful. And then don't code anything in your Controller but handle it through the use of a unique @ControllerAdvice class. Thus you will have only one algorithm to return 404/400 errors to your clients and not as many as you have APIs in your code.
Please see https://www.baeldung.com/exception-handling-for-rest-with-spring#controlleradvice