I have a REST service that takes an object containing an enum field as input. When a value not present in the enum is passed to me in input, a BAD REQUEST is automatically launched. I tried to go into debug to see where to handle the error but I notice that it doesn't really enter the method.
Retrieve interface:
@POST
@Path("/retrieve")
public Response retrieveValue(@Valid User user);
User:
public class User(){
String name;
String surname;
CityEnum city;
// getter and setter whith @NotNull annotation
}
CityEnum:
public enum CityEnum(){
LONDON("London"),
LIVERPOOL("Liverpool"),
...
private String city;
}
I need to return an error message and I assume the handling will be done in the RetrieveService which implements the Retrieve interface. How can this be done? I am using Mricroprofile.