How to throw an error message when there is no method mapping in Spring controller. In the following example GET /api/v1/foos doesn't exist, is there a way to throw a generic message (say api/v1/foos doesn't exist) instead of the default message.
{{base_url}}/fa/api/v1/foos/
{
"message": "No static resource api/v1/foos.",
"status": 500,
"timestamp": "2024-02-29T12:58:50.813294104"
}
You could define global elements in an ExceptionController or whatever you want to call it:
You can use custom classes, send parameters into those or simply use strings (as a parameter) for the message you want to send through these default exception classes.