Skip to content

Commit

Permalink
added detailed error log
Browse files Browse the repository at this point in the history
  • Loading branch information
anidotnet committed Oct 24, 2017
1 parent 42628ad commit 4f1aaa7
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public <T> Document asDocumentInternal(T object) {
JsonNode node = objectMapper.convertValue(object, JsonNode.class);
return loadDocument(node);
} catch (IllegalArgumentException iae) {
log.error("Error while converting object to document ", iae);
if (iae.getCause() instanceof JsonMappingException) {
JsonMappingException jme = (JsonMappingException) iae.getCause();
if (jme.getCause() instanceof StackOverflowError) {
Expand All @@ -73,12 +74,12 @@ public <T> T asObjectInternal(Document document, Class<T> type) {
try {
return getObjectMapper().convertValue(document, type);
} catch (IllegalArgumentException iae) {
log.error("Error while converting document to object ", iae);
if (iae.getCause() instanceof JsonMappingException) {
JsonMappingException jme = (JsonMappingException) iae.getCause();
if (jme.getMessage().contains("Can not construct instance")) {
throw new ObjectMappingException(errorMessage(
"no default parameter-less constructor found for "
+ type.getName(), OME_NO_DEFAULT_CTOR));
jme.getMessage(), OME_NO_DEFAULT_CTOR));
}
}
throw iae;
Expand Down Expand Up @@ -125,6 +126,7 @@ public Document parse(String json) {
JsonNode node = objectMapper.readValue(json, JsonNode.class);
return loadDocument(node);
} catch (IOException e) {
log.error("Error while parsing json", e);
throw new ObjectMappingException(errorMessage("failed to parse json " + json,
OME_PARSE_JSON_FAILED));
}
Expand All @@ -137,6 +139,7 @@ public String toJson(Object object) {
getObjectMapper().writeValue(stringWriter, object);
return stringWriter.toString();
} catch (IOException e) {
log.error("Error while serializing object to json", e);
throw new ObjectMappingException(JSON_SERIALIZATION_FAILED);
}
}
Expand Down

0 comments on commit 4f1aaa7

Please sign in to comment.