Open eedijs opened 1 year ago
Related to this issue - the FromMapConverter
creates a new instance of ObjectMapper
which has no registered modules, therefore I cannot convert an Instant
value from incoming json:
public class FromMapConverter implements Converter {
private static final ObjectMapper MAPPER = new ObjectMapper();
Do you have any plans for either using Spring Boot ObjectMapper
beans or making your instances of ObjectMapper
as configurable beans?
Can you add the Elide annotations to the example model or provide a working example based on Elide-spring-boot of the issue?
Apologies for the late reply, but I've updated my main comment's example with the same annotations that I use.
Hi @aklish, have you had the time to look at this issue? For now, I've implemented my custom ErrorMapper
, which changes the InvalidValueException
a bit and returns the same exception with a changed message (the verbose message contains the actual error):
private InvalidValueException getchangedInvalidValueException(Exception exception) {
InvalidValueException invalidValueException = (InvalidValueException) exception;
if (StringUtils.isEmpty(invalidValueException.getVerboseMessage())) {
return invalidValueException;
}
return new InvalidValueException(invalidValueException.getVerboseMessage().replace("Invalid value: ", ""), invalidValueException.getVerboseMessage());
}
Expected Behaviour
When a field receives an invalid value, return the error for it:
Current Behavior
Currently, the error message is very "cryptic" - it's impossible to tell what went wrong, which field was sent an invalid value. I will give you an example in
Steps to Reproduce
, but here's is the response I receive when a single or multiple values are invalid:Possible Solution
An improvement, in my opinion, would be to either show an error for the first field that fails and has an error, or even better - gather all fields with errors and list them in the response.
Steps to Reproduce (for bugs)
Here is a simple example class:
So if I send a request like this:
The error response for the invalid field will be:
Your Environment