Skip to content

Commit

Permalink
Updated error details for Assessment
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik-tarento committed Aug 3, 2023
1 parent 564c5ed commit 127e5e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,23 @@ public SBApiResponse readQuestionList(Map<String, Object> requestBody, String au
}
} else {
errMsg = Constants.FAILED_TO_GET_QUESTION_DETAILS;
logger.error(String.valueOf(new Exception("Failed to get Question Details for Ids")));
logger.error(errMsg, new Exception());
}
}
if (errMsg.isEmpty() && identifierList.size() == questionList.size()) {
response.getResult().put(Constants.QUESTIONS, questionList);
}
}
} catch (Exception e) {
logger.error(String.format("Exception in %s : %s", "get Question List", e.getMessage()), e);
errMsg = "Failed to fetch the question list. Exception: " + e.getMessage();
logger.error(errMsg, e);
}
if (StringUtils.isNotBlank(errMsg)) {
response.getParams().setStatus(Constants.FAILED);
response.getParams().setErrmsg(errMsg);
response.setResponseCode(HttpStatus.BAD_REQUEST);
}
return response;

}

private String validateAuthTokenAndFetchUserId(String authUserToken) {
Expand Down Expand Up @@ -656,7 +655,7 @@ private List<String> getQuestionIdList(Map<String, Object> questionListRequest)
}
}
} catch (Exception e) {
logger.error(String.format("Failed to process the questionList request body. %s", e.getMessage()));
logger.error(String.format("Failed to process the questionList request body. %s", e.getMessage()), e);
}
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public Map<String, Object> validateQumlAssessment(List<String> originalQuestionL
return resultMap;

} catch (Exception ex) {
logger.error("Error when verifying assessment. Error : ");
logger.error("Error when verifying assessment. Error : ", ex);
}
return new HashMap<>();
}
Expand Down Expand Up @@ -191,6 +191,7 @@ public String fetchQuestionIdentifierValue(List<String> identifierList, List<Obj
throws Exception {
List<String> newIdentifierList = new ArrayList<>();
newIdentifierList.addAll(identifierList);
String errMsg = "";

// Taking the list which was formed with the not found values in Redis, we are
// making an internal POST call to Question List API to fetch the details
Expand All @@ -205,16 +206,17 @@ public String fetchQuestionIdentifierValue(List<String> identifierList, List<Obj
if (!ObjectUtils.isEmpty(questionMap)) {
questionList.add(filterQuestionMapDetail(question, primaryCategory));
} else {
logger.error(String.format("Failed to get Question Details for Id: %s",
question.get(Constants.IDENTIFIER).toString()));
return "Failed to get Question Details for Id: %s";
errMsg = String.format("Failed to get Question Details for Id: %s",
question.get(Constants.IDENTIFIER).toString());
logger.error(errMsg);
return errMsg;
}
}
} else {
logger.error(
String.format("Failed to get Question Details from the Question List API for the IDs: %s",
newIdentifierList.toString()));
return "Failed to get Question Details from the Question List API for the IDs";
errMsg = String.format("Failed to get Question Details from the Question List API for the IDs: %s",
newIdentifierList.toString());
logger.error(errMsg);
return errMsg;
}
}
}
Expand Down Expand Up @@ -307,7 +309,7 @@ public Map<String, Object> getReadHierarchyApiResponse(String assessmentIdentifi
Map<String, Object> data = new ObjectMapper().convertValue(o, Map.class);
return data;
} catch (Exception e) {
logger.error("error in getReadHierarchyApiResponse " + e.getMessage());
logger.error("error in getReadHierarchyApiResponse " + e.getMessage(), e);
}
return new HashMap<>();
}
Expand Down

0 comments on commit 127e5e1

Please sign in to comment.