Is there a way to configure a Jackson ObjectMapper
to not include the source of the content it is trying to decode in error messages?
Simple example:
public class App {
public static class House {
String color;
}
public static void main(String[] args) {
try {
final var mapper = new ObjectMapper();
final var house = mapper.readValue("{\"name\": \"The Villa\"}\n", House.class);
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
}
This will print:
Unrecognized field "name" (class test.objectmapper.App$House), not marked as ignorable (0 known properties: ])
at [Source: (String)"{"name": "The Villa"}
"; line: 1, column: 11] (through reference chain: test.objectmapper.App$House["name"])
I would like it to not include the "Source" part. This can be important in an application where you want to limit the possibilities of sensitive data ending up in application logs.