REST POST endpoint receives a base64 string in the body. This body needs to be converted to a object. For that we have a custom Converter<String, CustomObject>.
We register it
public void addFormatters(FormatRegistry registry){
registry.addCOnverter(new CustomConverter());
}
In converter
public CustomObject convert(String string){
try{
return handle(string);
} catch (Exception e){
throw new CustomException("Unable to handle string", e);
}
}
What we would like is to get a status code 400 response with message:”Unable to handle string”, but what we get is whatever MethodArgumentNotValidException message is. Somewhere exception gets lost.
We also have DefaultHandlerExceptionResolver that should consturct the response, but the CustomException never reaches here, it gets swapped out before it gets here.
Anyway i can ensure that the error thrown by the COnverter reaches the client?