Skip to content

Commit

Permalink
minor change to fix response in case of createExp
Browse files Browse the repository at this point in the history
Signed-off-by: Saad Khan <[email protected]>
  • Loading branch information
khansaad committed Dec 4, 2023
1 parent 6a5d4c4 commit 753fb05
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,25 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
.create();
String gsonStr = gsonObj.toJson(new KruizeResponse(origMessage, errorCode, "", "ERROR", myList));

// Log messages based on httpcode
myList.forEach(updateResult ->
updateResult.getErrors().forEach(error -> {
if (error.getHttpcode() == 409) {
LOGGER.debug(gsonObj.toJson(error));
} else {
LOGGER.error(gsonObj.toJson(error));
}
})
);

// suppress error in case of duplicate records entry and show errors for all other failed cases.
// in case of createExp API, data object will be empty so 'myList' will be null
if (myList == null) {
if (errorCode == HttpServletResponse.SC_CONFLICT) {
LOGGER.debug(gsonStr);
} else {
LOGGER.error(gsonStr);
}
} else {
myList.forEach(failedResult ->
failedResult.getErrors().forEach(error -> {
if (error.getHttpcode() == 409) {
LOGGER.debug(gsonObj.toJson(error));
} else {
LOGGER.error(gsonObj.toJson(error));
}
})
);
}
out.append(gsonStr);
out.flush();
}
Expand Down

0 comments on commit 753fb05

Please sign in to comment.