updating live validator based on feedback

This commit is contained in:
Veronica Giaudrone 2017-08-03 15:17:14 -07:00
Родитель dbc63eb289
Коммит 75e5462566
2 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -21,7 +21,7 @@
*/
class LiveValidationError {
constructor(code, message) {
this.code = code.name;
this.code = code;
this.message = message;
}

Просмотреть файл

@ -222,7 +222,7 @@ class LiveValidator {
let liveValidationError;
if (path === null || path === undefined) {
msg = `Could not find path from requestUrl: "${requestUrl}".`;
liveValidationError = new models.LiveValidationError(Constants.ErrorCodes.PathNotFoundInRequestUrl, msg);
liveValidationError = new models.LiveValidationError(Constants.ErrorCodes.PathNotFoundInRequestUrl.name, msg);
result = new models.PotentialOperationsResult(potentialOperations, liveValidationError);
return result;
}
@ -282,7 +282,7 @@ class LiveValidator {
// Provide reason when we do not find any potential operaion in cache
if (potentialOperations.length === 0) {
liveValidationError = new models.LiveValidationError(code, msg);
liveValidationError = new models.LiveValidationError(code.name, msg);
}
result = new models.PotentialOperationsResult(potentialOperations, liveValidationError);
@ -359,7 +359,7 @@ class LiveValidator {
};
if (!requestResponseObj || (requestResponseObj && typeof requestResponseObj !== 'object')) {
let msg = 'requestResponseObj cannot be null or undefined and must be of type "object".';
let e = new models.LiveValidationError(Constants.ErrorCodes.IncorrectInput, msg);
let e = new models.LiveValidationError(Constants.ErrorCodes.IncorrectInput.name, msg);
validationResult.errors.push(e);
return validationResult;
}
@ -372,7 +372,7 @@ class LiveValidator {
} catch (err) {
let msg = `Found errors "${err.message}" in the provided input:\n` +
`${util.inspect(requestResponseObj, { depth: null })}.`;
let e = new models.LiveValidationError(Constants.ErrorCodes.IncorrectInput, msg);
let e = new models.LiveValidationError(Constants.ErrorCodes.IncorrectInput.name, msg);
validationResult.errors.push(e);
return validationResult;
}
@ -390,7 +390,7 @@ class LiveValidator {
} catch (err) {
let msg = `An error occured while trying to search for potential operations:\n` +
`${util.inspect(err, { depth: null })}`;
let e = new models.LiveValidationError(Constants.ErrorCodes.PotentialOperationSearchError, msg);
let e = new models.LiveValidationError(Constants.ErrorCodes.PotentialOperationSearchError.name, msg);
validationResult.errors.push(e);
return validationResult;
}
@ -418,7 +418,7 @@ class LiveValidator {
} catch (reqValidationError) {
let msg = `An error occurred while validating the live request for operation "${operation.operationId}". ` +
`The error is:\n ${util.inspect(requestValidationError, { depth: null })}`;
let err = new models.LiveValidationError(Constants.ErrorCodes.RequestValidationError, msg);
let err = new models.LiveValidationError(Constants.ErrorCodes.RequestValidationError.name, msg);
validationResult.requestValidationResult.errors = [err];
}
let resResult;
@ -430,7 +430,7 @@ class LiveValidator {
} catch (resValidationError) {
let msg = `An error occurred while validating the live response for operation "${operation.operationId}". ` +
`The error is:\n ${util.inspect(responseValidationError, { depth: null })}`;
let err = new models.LiveValidationError(Constants.ErrorCodes.ResponseValidationError, msg);
let err = new models.LiveValidationError(Constants.ErrorCodes.ResponseValidationError.name, msg);
validationResult.responseValidationResult.errors = [err];
}
if (reqResult && reqResult.errors && Array.isArray(reqResult.errors) && !reqResult.errors.length) {
@ -446,7 +446,7 @@ class LiveValidator {
let msg = `Found multiple matching operations with operationIds "${operationIds}" ` +
`for request url "${request.url}" with HTTP Method "${request.method}".`;
log.debug(msg);
let err = new models.LiveValidationError(Constants.ErrorCodes.MultipleOperationsFound, msg);
let err = new models.LiveValidationError(Constants.ErrorCodes.MultipleOperationsFound.name, msg);
validationResult.errors = [err];
}