...
...
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.
...
Current Scenarios of various exceptions
Info |
---|
The below exceptions are from release 5.6.0 |
Expand | ||
---|---|---|
|
...
|
...
Error Message
...
Thrown by?
...
ERR_API_CALL
...
Something Went Wrong While Making API Call | Error is: ??
...
Knowlg Core
...
ERR_QUESTION_CREATE
...
Visibility cannot be Parent!
...
inQuiry
...
ERR_QUESTION_SET_CREATE
...
Visibility cannot be Parent!
...
inQuiry
...
ERR_ACCESS_DENIED
...
?? visibility is private, hence access denied
...
inQuiry
...
ERR_INVALID_CHANNEL
...
Please Provide Channel!
...
inQuiry
...
ERR_ACCESS_DENIED
...
Channel id is not matched
...
inQuiry
...
ERR_QUESTION_UPDATE
...
?? with visibility Parent, can't be updated individually.
...
inQuiry
...
ERR_QUESTION_SET_UPDATE
...
?? with visibility Parent, can't be updated individually.
...
inQuiry
...
ERR_QUESTION_SET_REVIEW
...
?? with visibility Parent, can't be sent for review individually.
...
inQuiry
...
ERR_QUESTION_SET_REVIEW
...
?? with status other than Draft can't be sent for review.
...
inQuiry
...
title | ResourceNotFoundException |
---|
...
Error Code
...
Error Message
...
title | ServerException |
---|
...
Error Code
...
Error Message
...
ERR_QUESTION_SET_HIERARCHY
...
No hierarchy is present in cassandra for identifier: ??
...
ERR_QUESTIONSET_COPY
...
Something Went Wrong, Please Try Again
...
ERR_WHILE_FETCHING_HIERARCHY_FROM_CASSANDRA
...
Error while fetching hierarchy from cassandra
...
SERVER_ERROR
...
Invalid response from search
...
ERR_HIERARCHY_NOT_FOUND
...
No hierarchy is present in cassandra for identifier: ??
...
ERR_SYSTEM_EXCEPTION
...
Exception Occurred While Saving The Record. Exception is : ??
...
ERR_SYSTEM_EXCEPTION
...
Exception Occurred While Reading The Record. Exception is : ??
...
ERR_GRAPH_PROCESSING_ERROR
...
Unable To Fetch Nodes From Graph. Exception is: ??
...
ERR_INVALID_REQUEST_BODY
...
Request Body is Missing!
...
ERR_API_CALL
...
Something Went Wrong While Making API Call | Error is: ??
...
ERR_INVALID_URL
...
Url Parameter is Missing!
...
ERR_INVALID_HEADER_PARAM
...
Header Parameter is Missing!
...
ERR_DATA_PARSER
...
Unable to parse data! | Error is: ??
...
ERR_KEYSPACE_NOT_DEFINED
...
Key space for ?? is not configured.
API Error Responses from inQuiry microservice
...
title | 400 Bad Request |
---|
...
API Functionality
...
HTTP Error Code
...
Existing Error Response
...
Proposed Error Response
...
Question Create
...
400 Bad Request
...
|
Expand | |||||
---|---|---|---|---|---|
| |||||
|
Expand | |||||
---|---|---|---|---|---|
| |||||
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
Question Create
...
400 Bad Request
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
Question Create
...
400 Bad Request
...
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
API Error Responses from inQuiry microservice
Expand | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Expand | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Info |
---|
Expand | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||
| QuestionSet Add Children | 404 Not Found | ||||||||||||||||||||||||||
Code Block |
"source": { " |
pointer": " |
name" }, " |
detail": " |
Required Metadata name not set." }, { " |
code": |
"1001", " |
source": { "pointer": "code" }, " |
detail": " |
Required Metadata code not set." |
}, { " |
code": " |
1002", "source": { " |
pointer": " |
mimeType" }, |
" |
detail": " |
Required Metadata mimeType not set." } |
|
]
} |
Info | |
---|---|
We can reserve error codes for the parent category of errors, something like outlined below, CLIENT_ERROR - 10000 to 20000 RESOURCE_NOT_FOUND ", "result": { "messages": null } } | QuestionSet Remove Children | 404 Not Found
Info |
---|
The Error class will be part of knowlg core |
Sample code for exception,
Code Block |
---|
throw new ClientException("ERR_INVALID_REQUEST", "A summary of the error", listOfErrors; |
Solution 2
Preparing a key / value of the field with the error and corresponding message.
Expand | ||
---|---|---|
| ||
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
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.
Info |
---|
Expand | ||
---|---|---|
| ||
|
Info |
---|
We can reserve error codes for the parent category of errors, something like outlined below, CLIENT_ERROR - 10000 to 20000 RESOURCE_NOT_FOUND - 20001 to 30000 SERVER_ERROR - 30001 to 40000 |
Solution 2
Preparing a key / value of the field with the error and corresponding message.
Expand | ||
---|---|---|
| ||
|
...
|
One limitation with this approach is if there are multiple errors to be returned on the same field, then it becomes difficult.
Sample code for exception,
Code Block |
---|
throw new ClientException("ERR_INVALID_REQUEST", "A summary of the error", mapOfErrors); |
Proposed Error Category and Definitions
Info |
---|
ClientException - Can the client recover from an error by fixing the error and resubmitting? ResourceNotFoundException - The resource that is requested by the client is not found in the server. Client can recover from this error by correcting the mistake if possible. ServerException - May be a external API call failed. Nothing for the client to fix an resubmit, but in some case can be retried |
- Recheck if we are using the right exception in the right context
Error Category | HTTP Error Code | Error Sub Category | Error Code | Scenarios Applicable |
---|---|---|---|---|
ERR_INVALID_REQUEST | 400 | ERR_MANDATORY_FIELD_MISSING | Mandatory attributes are missing or missing values
| |
ERR_INVALID_REQUEST | 400 | ERR_INVALID_PROPERTY_SUPPLIED | 1000 | When property is invalid or given in wrong place in the request
|
ERR_INVALID_REQUEST | 400 | ERR_INVALID_VALUE_SUPPLIED | Request has an invalid value when validating
| |
ERR_INVALID_REQUEST | 400 | ERR_VALUE_CANNOT_BE_EMPTY | 1001 | In case of conditionally required and not always mandatory
|
400 | ERR_OPERATION_NOT_PERMITTED | Errors due to the current state of the resource
| ||
400 | ERR_RESOURCE_STATE_INVALID | State or status of the resource is not in the desired form for carrying out the current operation
| ||
ERR_RESOURCE_NOT_FOUND | 404 | ERR_RESOURCE_NOT_FOUND | The requested resource is not found in the server
| |
ERR_SERVER_EXCEPTION | 500 | ERR_API_CALL | Exception occurred while making API calls | |
ERR_SERVER_EXCEPTION | 500 | ERR_JOB_SUBMISSION | Exception occurred when submitting the jobs
| |
ERR_SERVER_EXCEPTION | 500 | ERR_DATA_STORE | Exception occurred while performing operation against the various data stores | |
ERR_SERVER_EXCEPTION | 500 | ERR_DATA_PARSING | Exception occurred while parsing the input data | |
ERR_SERVER_EXCEPTION | 500 | ERR_SYSTEM_EXCEPTION | Other exception occurred in the server side |