我的IDE是给我的错误Unhandled Exception com.fasterxml.jackson.databind.JsonMappingException
与mapper.readValue
线无法赶上JsonMappingException
ObjectMapper mapper = new ObjectMapper();
try {
if (response.isEmpty()) {
//Http 204 (No Content) returned from MCC
//We should handle this differently
user = new User();
} else {
user = mapper.readValue(response, User.class);
}
} catch (IOException ioe) {
logger.log(Level.SEVERE, ioe.getLocalizedMessage());
}
return user;
我试图捕捉JsonMappingException
但它并没有让错误消失。有什么想法吗?
您需要为特定类型的Exception添加一个catch块。尝试'catch(JsonMappingException jme){}' –
我试过......当我这样做时,它说'Required:java.lang.Throwable'就好像那个Exception不能被抛出一样。 – Webnet