This document explains about the various error responses the inQuiry micro service currently throws. The intent of this document is to look through the errors and classify it and propose any changes in terms of error reporting.
Broadly classified, there are three types of error responses that are coming out of the APIs.
Error Classification
HTTP Status Code
Description / Usage
Error Classification
HTTP Status Code
Description / Usage
CLIENT_ERROR
400
The client sends a bad request that resulted in service validating and throwing the error.
RESOURCE_NOT_FOUND
404
The client request for a resource that is not found in the server.
SERVER_ERROR
500
Service resulted in unexpected results while processing the client request.
Class
ClientException
assessment-actors (31 usages found)
org.sunbird.managers (26 usages found)
AssessmentManager.scala (22 usages found)
34 throw new ClientException(errCode, "Visibility cannot be Parent!")
53 throw new ClientException("ERR_ACCESS_DENIED", s"$resName visibility is private, hence access denied")
61 if (StringUtils.isBlank(request.getRequest.getOrDefault("channel", "").asInstanceOf[String])) throw new ClientException("ERR_INVALID_CHANNEL", "Please Provide Channel!")
69 throw new ClientException("ERR_ACCESS_DENIED", "Channel id is not matched")
83 throw new ClientException(errCode, node.getMetadata.getOrDefault("objectType", "").asInstanceOf[String].replace("Image", "") + " with visibility Parent, can't be updated individually.")
92 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} with visibility Parent, can't be sent for review individually.")
94 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} with status other than Draft can't be sent for review.")
107 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} with visibility Parent, can't be sent for review individually.")
109 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} with status other than Draft can't be sent for review.")
112 throw new ClientException("ERR_MANDATORY_FIELD_VALIDATION", s"Mandatory Fields ${messages.asJava} Missing for ${node.getIdentifier.replace(".img", "")}")
139 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} with visibility Parent, can't be sent for publish individually.")
141 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} having Processing status can't be sent for publish.")
152 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} with visibility Parent, can't be sent for publish individually.")
154 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} having Processing status can't be sent for publish.")
157 throw new ClientException("ERR_MANDATORY_FIELD_VALIDATION", s"Mandatory Fields ${messages.asJava} Missing for ${node.getIdentifier.replace(".img", "")}")
165 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} with identifier : ${node.getIdentifier} is already Retired.")
174 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} with visibility Parent, can't be sent for reject individually.")
176 throw new ClientException(errCode, s"${node.getObjectType.replace("Image", "")} is not in 'Review' state for identifier: " + node.getIdentifier)
185 throw new ClientException("ERR_QUESTION_SET_ADD", "Node with Identifier " + node.getIdentifier + " is not a Question Set")
216 throw new ClientException("ERR_QUESTION_SET", "Object with identifier: " + content.get("identifier") + " is not Live. Please Publish it.")
237 throw new ClientException("ERR_MANDATORY_FIELD_VALIDATION", s"Mandatory Fields ${messages.asJava} Missing for ${content.get("identifier").toString}")
284 if (StringUtils.isBlank(beJobRequestEvent)) throw new ClientException("BE_JOB_REQUEST_EXCEPTION", "Event is not generated properly.")
CopyManager.scala (4 usages found)
61 requestObjectType, nodeObjectType)) throw new ClientException(AssessmentConstants.ERR_INVALID_OBJECT_TYPE, s"Please Provide Valid ${requestObjectType} Identifier
63 throw new ClientException(AssessmentConstants.ERR_INVALID_REQUEST, "Question With Visibility Parent Cannot Be Copied Individually!")
270 throw new ClientException(AssessmentConstants.ERR_INVALID_REQUEST, "Please provide valid value for " + keysNotPresent)
276 throw new ClientException(AssessmentConstants.ERR_INVALID_REQUEST, "QuestionSet With Status " + node.getMetadata.get(AssessmentConstants
org.sunbird.utils (5 usages found)
RequestUtil.scala (5 usages found)
24 getRequest.containsKey(prop))) throw new ClientException("ERROR_RESTRICTED_PROP", "Properties in list " + restrictedProps.mkString("[", ", ", "]") + " are not
29 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), s"Request Body cannot be Empty.")
32 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), s"Cannot update content status to : ${SYSTEM_UPDATE_ALLOWED_CONTENT_STATUS.mkString("[", ", ", "]")}.")
38 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), "Required field identifier is missing or empty.")
41 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), "Request contains more than the permissible limit of identifiers: " + reqSize + ". Permissible limit is: "+questionListLimit)
qs-hierarchy-manager (24 usages found)
org.sunbird.managers (24 usages found)
HierarchyManager.scala (11 usages found)
124 throw new ClientException("ERR_BRANCHING_LOGIC", s"Branching Is Not Enabled For ${rootNode.getIdentifier}. Please Enable Branching Or Remove branchingLogic from Request.")
255 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), "rootId is mandatory")
258 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), "children are mandatory")
262 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), "Branch Rule Found For The Node Which Is Not A Children Having Identifier
281 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), "Children which are not available are: " + filteredList)
285 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), s"Children must be of types $ASSESSMENT_OBJECT_TYPES for ids: ${invalidNodes.map(_.getIdentifier)}")
320 throw new ClientException("ERR_BRANCHING_LOGIC", s"Branching Is Not Enabled For ${unitId}. Please Enable Branching Or Remove branchingLogic from Request.")
696 throw new ClientException("ERR_BRANCHING_LOGIC", s"Dependent Children Found! Please Remove Children With Identifiers ${target} For Node : ${identifier}")
708 throw new ClientException("ERR_BRANCHING_LOGIC", s"Source With Identifiers ${sourceIds.diff(childrenIds).asJava} Not Found! Please Provide Valid Source Identifier.")
716 throw new ClientException("ERR_BRANCHING_LOGIC", "An Object Can't Depend On More Than 1 Object")
721 throw new ClientException("ERR_BRANCHING_LOGIC", s"${source.get(0)} Is Already Children Of ${pSource.get(0)}. So It Can't Be Parent For ${entry._1}")
UpdateHierarchyManager.scala (13 usages found)
66 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), "Hierarchy data is empty")
72 throw new ClientException("ERR_QS_UPDATE_HIERARCHY", "Question cannot have children in hierarchy")
90 throw new ClientException(HierarchyErrorCodes.ERR_INVALID_ROOT_ID, "Please Provide Valid Root Node Identifier")
102 throw new ClientException(HierarchyErrorCodes.ERR_INVALID_ROOT_ID, "Invalid MimeType for Root Node Identifier : " + identifier)
106 throw new ClientException(HierarchyErrorCodes.ERR_INVALID_ROOT_ID, "Invalid Visibility found for Root Node Identifier : " + identifier)
195 throw new ClientException("ERR_UPDATE_QS_HIERARCHY", s"Object Type is mandatory for creation of node with id: ${nodeModified._1}")
198 throw new ClientException("ERR_UPDATE_QS_HIERARCHY", s"Visibility can be only of type Parent for identifier: ${nodeModified._1}")
200 throw new ClientException("ERR_UPDATE_QS_HIERARCHY", s"Visibility can be only of type ${HierarchyConstants.QUESTION_VISIBILITY.asJava} for identifier: ${nodeModified._1}")
524 throw new ClientException("ERR_BRANCHING_LOGIC", s"Branching Is Not Enabled For: ${node.getIdentifier}. Please Remove branchingLogic from ${node.getIdentifier}")
541 throw new ClientException("ERR_BRANCHING_LOGIC", s"Please Provide Branching Rules for : ${branchingLogic.keySet.toList.diff(target).asJava}")
544 throw new ClientException("ERR_BRANCHING_LOGIC", s"Please Provide Dependent Object Within Same Parent having identifier : ${node.getIdentifier}")
547 throw new ClientException("ERR_BRANCHING_LOGIC", "An Object Can't Depend On More Than 1 Object")
550 throw new ClientException("ERR_BRANCHING_LOGIC", "A Dependent Object Can't Have Further Dependent Object")
Maven: org.sunbird:graph-engine_2.11:1.0-SNAPSHOT (18 usages found)
src.main.scala.org.sunbird.graph.nodes (6 usages found)
DataNode.scala (6 usages found)
77 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), "identifiers is mandatory")
179 else throw new ClientException("ERR_INVALID_RELATION_OBJECT", "Invalid Relation Object Found.")
216 if (metadata.isEmpty) throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), s"Invalid Request. Cannot update status of Image Node to $status.")
261 throw new ClientException(ResponseCode.RESOURCE_NOT_FOUND.name(), s"Error! Node(s) doesn't Exists with identifier : ${request.getContext.get("identifier")}.")
266 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), s"Cannot update content with FAILED status for id : ${node.getIdentifier}.")
304 throw new ClientException(ErrorCodes.ERR_BAD_REQUEST.name(), s"Request contains invalid identifiers : ${missingIds.mkString("[", ", ", "]")}.")
src.main.scala.org.sunbird.graph.relations (2 usages found)
RelationHandler.scala (2 usages found)
18 throw new ClientException(GraphErrorCodes.ERR_RELATION_CREATE.toString, "UnSupported Relation: " + relationType)
21 throw new ClientException(GraphErrorCodes.ERR_RELATION_CREATE.toString, "UnSupported Relation: " + relationType)
src.main.scala.org.sunbird.graph.schema (1 usage found)
DefinitionDTO.scala (1 usage found)
126 throw new ClientException(ResponseCode.CLIENT_ERROR.name, "Invalid request", java.util.Arrays.asList("Invalid Props are : " + invalidProps.asJavaCollection))
src.main.scala.org.sunbird.graph.schema.validator (9 usages found)
FrameworkValidator.scala (2 usages found)
52 case _ => throw new ClientException("CLIENT_ERROR", "Validation Errors.", util.Arrays.asList("Please provide correct value for [" + cat + "]"))
64 throw new ClientException("CLIENT_ERROR", "Validation Errors.", errors)
PropAsEdgeValidator.scala (4 usages found)
30 throw new ClientException("ERR_INVALID_EDGE_PROPERTY", key + " value should be one of " + list)
34 throw new ClientException("ERR_INVALID_EDGE_PROPERTY", key + " value should be any of " + list)
36 throw new ClientException("ERR_INVALID_EDGE_PROPERTY", key + " given datatype is invalid.")
39 throw new ClientException("ERR_EMPTY_EDGE_PROPERTY_LIST", "The list to validate input is empty.")
RelationValidator.scala (1 usage found)
45 throw new ClientException(ResponseCode.CLIENT_ERROR.name, "Error while validating relations :: " + errList)
VersionKeyValidator.scala (2 usages found)
26 if(!isValid)throw new ClientException(ResponseCode.CLIENT_ERROR.name, "Invalid version Key")
55 throw new ClientException("BLANK_VERSION", "Error! Version Key cannot be Blank. | [Node Id: " + node.getIdentifier + "]")
Maven: org.sunbird:platform-common:1.0-SNAPSHOT (10 usages found)
org.sunbird.common (2 usages found)
HttpUtil (2 usages found)
getMetadata(String, Map<String, String>) (2 usages found)
79 throw new ClientException("ERR_API_CALL", "Fetching of file related metadata Failed with response code " + response.getStatus() + " and message: " + response.getStatusText());
82 throw new ClientException("ERR_API_CALL", "Something Went Wrong While Making API Call | Error is: " + e.getMessage());
Maven: org.sunbird:schema-validator:1.0-SNAPSHOT (1 usage found)
org.sunbird.schema.dto (1 usage found)
ValidationResult (1 usage found)
ValidationResult(List<String>, Map<String, Object>, Map<String, Object>, Map<String, Object>) (1 usage found)
28 throw new ClientException(ResponseCode.CLIENT_ERROR.name(), "Validation Errors", messages);
Â
Class
ResourceNotFoundException
New instance creation (14 usages found)
qs-hierarchy-manager (2 usages found)
org.sunbird.managers (2 usages found)
UpdateHierarchyManager.scala (2 usages found)
267 throw new ResourceNotFoundException("ERR_UPDATE_QS_HIERARCHY", s"No node found with id: $nodeId")
288 } else throw new ResourceNotFoundException(HierarchyErrorCodes.ERR_CONTENT_NOT_FOUND, "Content not found with identifier: " + nodeId)
Maven: org.sunbird:graph-engine_2.11:1.0-SNAPSHOT (6 usages found)
src.main.scala.org.sunbird.graph.schema (2 usages found)
CategoryDefinitionValidator.scala (2 usages found)
56 throw new ResourceNotFoundException(resp.getParams.getErr, resp.getParams.getErrmsg + " " + resp.getResult)
62 throw new ResourceNotFoundException(channelCatResp.getParams.getErr, channelCatResp.getParams.getErrmsg + " " + channelCatResp.getResult)
src.main.scala.org.sunbird.graph.schema.validator (4 usages found)
FrameworkValidator.scala (3 usages found)
182 throw new ResourceNotFoundException("ERR_VALIDATING_CONTENT_FRAMEWORK", s"Nodes not found for Id's $ids ")
195 throw new ResourceNotFoundException("ERR_VALIDATING_CONTENT_FRAMEWORK", s"No nodes found for $termName with ids: ${node.getMetadata.get(termName)}")
197 throw new ResourceNotFoundException("ERR_VALIDATING_CONTENT_FRAMEWORK", s"No nodes found for $termName with ids: ${node.getMetadata.get(termName)}")
VersioningNode.scala (1 usage found)
44 throw new ResourceNotFoundException(GraphErrorCodes.ERR_INVALID_NODE.toString, "Node Not Found With Identifier : " + identifier)
Class
ServerException
assessment-actors (3 usages found)
org.sunbird.managers (3 usages found)
AssessmentManager.scala (1 usage found)
207 } else throw new ServerException("ERR_QUESTION_SET_HIERARCHY", "No hierarchy is present in cassandra for identifier:" + rootNode.getIdentifier)
CopyManager.scala (2 usages found)
107 throw new ServerException("ERR_QUESTIONSET_COPY", "Something Went Wrong, Please Try Again")
116 throw new ServerException("ERR_QUESTIONSET_COPY", "Something Went Wrong, Please Try Again")
qs-hierarchy-manager (4 usages found)
org.sunbird.managers (4 usages found)
HierarchyManager.scala (3 usages found)
488 throw new ServerException("ERR_WHILE_FETCHING_HIERARCHY_FROM_CASSANDRA", "Error while fetching hierarchy from cassandra")
493 throw new ServerException("ERR_WHILE_FETCHING_HIERARCHY_FROM_CASSANDRA", "Error while fetching hierarchy from cassandra")
575 throw new ServerException("SERVER_ERROR", "Invalid response from search")
UpdateHierarchyManager.scala (1 usage found)
128 throw new ServerException(HierarchyErrorCodes.ERR_HIERARCHY_NOT_FOUND, "No hierarchy is present in cassandra for identifier:" + rootNode.getIdentifier)
Maven: org.sunbird:graph-engine_2.11:1.0-SNAPSHOT (9 usages found)
src.main.scala.org.sunbird.graph.external.store (5 usages found)
ExternalStore.scala (5 usages found)
49 throw new ServerException(ErrorCodes.ERR_SYSTEM_EXCEPTION.name, "Exception Occurred While Saving The Record. Exception is : " + e.getMessage)
92 throw new ServerException(ErrorCodes.ERR_SYSTEM_EXCEPTION.name, "Exception Occurred While Reading The Record. Exception is : " + e.getMessage)
110 throw new ServerException(ErrorCodes.ERR_SYSTEM_EXCEPTION.name, "Exception Occurred While Reading The Record. Exception is : " + e.getMessage)
150 throw new ServerException(ErrorCodes.ERR_SYSTEM_EXCEPTION.name, "Exception Occurred While Reading The Record. Exception is : " + e.getMessage)
181 throw new ServerException(ErrorCodes.ERR_SYSTEM_EXCEPTION.name, "Exception Occurred While Saving The Record. Exception is : " + e.getMessage)
src.main.scala.org.sunbird.graph.relations (2 usages found)
AbstractRelation.scala (1 usage found)
66 throw new ServerException(GraphErrorCodes.ERR_RELATION_VALIDATE.toString, "Error occurred while validating the relation", e)
SequenceMembershipRelation.scala (1 usage found)
25 throw new ServerException(GraphErrorCodes.ERR_RELATION_VALIDATE.toString, e.getMessage, e)
src.main.scala.org.sunbird.graph.schema (1 usage found)
CategoryDefinitionValidator.scala (1 usage found)
65 } else throw new ServerException(resp.getParams.getErr, resp.getParams.getErrmsg + " " + resp.getResult)
src.main.scala.org.sunbird.graph.schema.validator (1 usage found)
FrameworkValidator.scala (1 usage found)
152 throw new ServerException("ERR_GRAPH_PROCESSING_ERROR", "Unable To Fetch Nodes From Graph. Exception is: " + e.getMessage)
Maven: org.sunbird:platform-common:1.0-SNAPSHOT (13 usages found)
org.sunbird.common (7 usages found)
HttpUtil (7 usages found)
post(String, Map<String, Object>, Map<String, String>) (2 usages found)
33 throw new ServerException("ERR_INVALID_REQUEST_BODY", "Request Body is Missing!");
38 throw new ServerException("ERR_API_CALL", "Something Went Wrong While Making API Call | Error is: " + e.getMessage());
get(String, String, Map<String, String>) (1 usage found)
58 throw new ServerException("ERR_API_CALL", "Something Went Wrong While Making API Call | Error is: " + e.getMessage());
getMetadata(String, Map<String, String>) (1 usage found)
84 throw new ServerException("ERR_API_CALL", "Something Went Wrong While Making API Call | Error is: " + e.getMessage());
validateRequest(String, Map<String, String>) (2 usages found)
90 throw new ServerException("ERR_INVALID_URL", "Url Parameter is Missing!");
92 throw new ServerException("ERR_INVALID_HEADER_PARAM", "Header Parameter is Missing!");
getResponse(HttpResponse<String>) (1 usage found)
100 throw new ServerException("ERR_DATA_PARSER", "Unable to parse data! | Error is: " + e.getMessage());
Maven: org.sunbird:schema-validator:1.0-SNAPSHOT (1 usage found)
org.sunbird.schema (1 usage found)
SchemaValidatorFactory (1 usage found)
getExternalStoreName(String, String) (1 usage found)
39 throw new ServerException("ERR_KEYSPACE_NOT_DEFINED", "Key space for " + name + " is not configured.");
API Error Responses from inQuiry microservice
Â
API Functionality
HTTP Error Code
Existing Error Response
API Functionality
HTTP Error Code
Existing Error Response
Question Create
400 Bad Request
Question Create
400 Bad Request
Question Create
400 Bad Request
Question Create
400 Bad Request
Question Create
400 Bad Request
Question Update
400 Bad Request
Question Review
400 Bad Request
Question Review
400 Bad Request
Question Review
400 Bad Request
Question Review
400 Bad Request
Question Publish
400 Bad Request
Question Publish
400 Bad Request
Question Publish
400 Bad Request
Question Publish
400 Bad Request
Question List
400 Bad Request
Question List
400 Bad Request
Question Import
400 Bad Request
Question Import
400 Bad Request
Question Reject
400 Bad Request
QuestionSet Create
400 Bad Request
QuestionSet Create
400 Bad Request
QuestionSet Create
400 Bad Request
QuestionSet Update
200 OK
??
QuestionSet Update Hierarchy
400 Bad Request
QuestionSet Review
400 Bad Request
QuestionSet Publish
400 Bad Request
QuestionSet Retire
400 Bad Request
QuestionSet Reject
400 Bad Request
QuestionSet Import
400 Bad Request
QuestionSet Import
400 Bad Request
QuestionSet Add Children
400 Bad Request
QuestionSet Remove Children
400 Bad Request
Â
Proposed Error Response
Solution 1
Recommendation is to use the error standards as specified in the http://jsonapi.org
code: an application-specific error code, expressed as a string value.
title: a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
detail: a human-readable explanation specific to this occurrence of the problem. Like title, this field’s value can be localized.
source: an object containing references to the primary source of the error. It SHOULD include one of the following members or be omitted:
pointer : a JSON Pointer to the value in the request document that caused the error
parameter: a string indicating which URI query parameter caused the error.
header : a string indicating the name of a single request header which caused the error.