INNER CODE UNIT · JavaScript
getErrorCode
sisense/graphql2rest · src/errorHandling.js:25
const getErrorCode = (response) => {
const errorCodePath = config.graphqlErrorCodeObjPath || consts.DEFAULT_ERROR_CODE_PATH;
if (!response
|| !errorMap
|| !errorMap.errorCodes
|| Object.keys(errorMap.errorCodes).length === 0) return null;
const gqlErrorCode = dot.pick(errorCodePath, response);
if (gqlErrorCode === undefined) return null;
const errorFound = errorMap.errorCodes[gqlErrorCode];
return errorFound && errorFound.httpCode ? errorFound.httpCode : null;
};
/* Adds custom error string to the first error */
const attachCustomErrorDescription = (response) => {
const errorCodePath = config.graphqlErrorCodeObjPath || consts.DEFAULT_ERROR_CODE_PATH;
const gqlErrorCode = dot.pick(errorCodePath, response);
if (response && response.errors && response.errors[0] && gqlErrorCode !== undefined) {