I want to set custom error Message for Unrecognized field and others errors with request body. I tried ExceptionMapper but it dont work :/ Using quarkus and Jackson
public class ReqDTO {
private String a;
}
when send request:
{
"a": "a"
}
its look good. But when send:
{
"a": "a",
"b": "b"
}
have error response:
Unrecognized field "b"; (class ReqDTO), not marked as ignorable
Want customize this message and other bad json body (like too much fields) to own message like "BAD_JSON_SCHEMA".
Tried
@Provider
public class ExHandler implements ExceptionMapper<JsonMappingException>{
public Respone toResponse(JsonMappingException e) {
//response bad field impl
}
}
But its not work. Looks like a json handle exception faster. Tried with "Exception", "JsonParseException" but nothing changed :/
@Path("/")
public class Controller {
@Post
@Consume(APPLICATION_JSON)
@Produces(TEXT_PLAIN)
public Response getA(@Valid ReqDTO reqDTO){
//logic
}
}
@Edit
Found something like DeserializationProblemHandler but dont know how change message for handleUnknownProperty :/