This commit is contained in:
2020-12-09 20:11:12 +00:00
parent 59f825bb36
commit fca43b0f61
8 changed files with 66 additions and 62 deletions

View File

@@ -12,58 +12,59 @@ namespace AyaNova.Biz
internal static class ApiErrorCodeStockMessage
{
internal static string GetMessage(ApiErrorCode code)
internal static string GetTranslationCodeForApiErrorCode(ApiErrorCode code)
{
switch (code)
{
case ApiErrorCode.API_CLOSED:
return "API Closed";
case ApiErrorCode.API_OPS_ONLY:
return "API Closed to non operations routes";
case ApiErrorCode.API_SERVER_ERROR:
return "Server internal error, details in server log file";
case ApiErrorCode.AUTHENTICATION_FAILED:
return "Authentication failed";
case ApiErrorCode.NOT_AUTHORIZED:
return "User not authorized for this resource operation (insufficient rights)";
case ApiErrorCode.CONCURRENCY_CONFLICT:
return "Object was changed by another user since retrieval (concurrency token mismatch)";
case ApiErrorCode.NOT_FOUND:
return "Object not found";
case ApiErrorCode.PUT_ID_MISMATCH:
return "Update failed: ID mismatch - route ID doesn't match object id";
case ApiErrorCode.INVALID_OPERATION:
return "An attempt was made to perform an invalid operation";
case ApiErrorCode.VALIDATION_FAILED:
return "Object did not pass validation";
case ApiErrorCode.VALIDATION_REQUIRED:
return "Required field empty";
case ApiErrorCode.VALIDATION_LENGTH_EXCEEDED:
return "Field too long";
case ApiErrorCode.VALIDATION_INVALID_VALUE:
return "Field is set to a non allowed value";
case ApiErrorCode.VALIDATION_CUSTOM_REQUIRED_EMPTY:
return "Customized form property is set to required but has an empty value";
case ApiErrorCode.VALIDATION_MISSING_PROPERTY:
return "Required property is missing entirel";
case ApiErrorCode.VALIDATION_NOT_UNIQUE:
return "Field is required to be unique but an existing record with an identical value was found in the database";
case ApiErrorCode.VALIDATION_STARTDATE_AFTER_ENDDATE:
return "The start date must be earlier than the end date";
case ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY:
return "Modifying the object (usually a delete) would break the link to other records in the database and operation was disallowed to preserve data integrity";
case ApiErrorCode.VALIDATION_NOT_CHANGEABLE:
return "the value is fixed and cannot be changed";
case ApiErrorCode.CHILD_OBJECT_ERROR:
return "Errors in child object during operation";
return $"ErrorAPI"+((int)code).ToString();
// switch (code)
// {
// case ApiErrorCode.API_CLOSED:
// return "API Closed";
// case ApiErrorCode.API_OPS_ONLY:
// return "API Closed to non operations routes";
// case ApiErrorCode.API_SERVER_ERROR:
// return "Server internal error, details in server log file";
// case ApiErrorCode.AUTHENTICATION_FAILED:
// return "Authentication failed";
// case ApiErrorCode.NOT_AUTHORIZED:
// return "User not authorized for this resource operation (insufficient rights)";
// case ApiErrorCode.CONCURRENCY_CONFLICT:
// return "Object was changed by another user since retrieval (concurrency token mismatch)";
// case ApiErrorCode.NOT_FOUND:
// return "Object not found";
// case ApiErrorCode.PUT_ID_MISMATCH:
// return "Update failed: ID mismatch - route ID doesn't match object id";
// case ApiErrorCode.INVALID_OPERATION:
// return "An attempt was made to perform an invalid operation";
// case ApiErrorCode.VALIDATION_FAILED:
// return "Object did not pass validation";
// case ApiErrorCode.VALIDATION_REQUIRED:
// return "Required field empty";
// case ApiErrorCode.VALIDATION_LENGTH_EXCEEDED:
// return "Field too long";
// case ApiErrorCode.VALIDATION_INVALID_VALUE:
// return "Field is set to a non allowed value";
// case ApiErrorCode.VALIDATION_CUSTOM_REQUIRED_EMPTY:
// return "Customized form property is set to required but has an empty value";
// case ApiErrorCode.VALIDATION_MISSING_PROPERTY:
// return "Required property is missing entirel";
// case ApiErrorCode.VALIDATION_NOT_UNIQUE:
// return "Field is required to be unique but an existing record with an identical value was found in the database";
// case ApiErrorCode.VALIDATION_STARTDATE_AFTER_ENDDATE:
// return "The start date must be earlier than the end date";
// case ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY:
// return "Modifying the object (usually a delete) would break the link to other records in the database and operation was disallowed to preserve data integrity";
// case ApiErrorCode.VALIDATION_NOT_CHANGEABLE:
// return "the value is fixed and cannot be changed";
// case ApiErrorCode.CHILD_OBJECT_ERROR:
// return "Errors in child object during operation";
default:
return null;
// default:
// return null;
}
// }
}
/*
API_CLOSED = 2000,