Skip to content

Commit

Permalink
modifying the error JSON response
Browse files Browse the repository at this point in the history
the requestUrl will only be included when a GET request was sent
  • Loading branch information
kowatsch committed May 18, 2018
1 parent 476bfdd commit fa0bf28
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ public Map<String, Object> getErrorAttributes(RequestAttributes requestAttribute
errorAttributes.remove("exception");
errorAttributes.put("timestamp",
LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME));
if (errorAttributes.get("message").toString().equals("No message available"))
if (errorAttributes.get("message").toString().equals("No message available")) {
errorAttributes.remove("requestUrl");
else
errorAttributes.put("requestUrl", RequestInterceptor.requestUrl);
} else {
// ensures to include the requestUrl in the error-response only if a GET request was sent
if (!RequestInterceptor.requestUrl.split("\\?")[1].equals("null"))
errorAttributes.put("requestUrl", RequestInterceptor.requestUrl);
}
return errorAttributes;
}
};
Expand Down

0 comments on commit fa0bf28

Please sign in to comment.