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

@@ -30,7 +30,7 @@ namespace AyaNova.Api.ControllerHelpers
//try to get a stock message if nothing specified
if (message == null)
{
message = ApiErrorCodeStockMessage.GetMessage(apiCode);
message = ApiErrorCodeStockMessage.GetTranslationCodeForApiErrorCode(apiCode);
}
Error = new ApiError(apiCode, message, target);
@@ -52,7 +52,7 @@ namespace AyaNova.Api.ControllerHelpers
//Set outer error and then put validation in details
Error = new ApiError(ApiErrorCode.VALIDATION_FAILED, ApiErrorCodeStockMessage.GetMessage(ApiErrorCode.VALIDATION_FAILED));
Error = new ApiError(ApiErrorCode.VALIDATION_FAILED, ApiErrorCodeStockMessage.GetTranslationCodeForApiErrorCode(ApiErrorCode.VALIDATION_FAILED));
//https://www.jerriepelser.com/blog/validation-response-aspnet-core-webapi/
@@ -88,7 +88,7 @@ namespace AyaNova.Api.ControllerHelpers
//Business rule validation error response
public ApiErrorResponse(List<ValidationError> errors)
{
Error = new ApiError(ApiErrorCode.VALIDATION_FAILED, ApiErrorCodeStockMessage.GetMessage(ApiErrorCode.VALIDATION_FAILED));
Error = new ApiError(ApiErrorCode.VALIDATION_FAILED, ApiErrorCodeStockMessage.GetTranslationCodeForApiErrorCode(ApiErrorCode.VALIDATION_FAILED));
Error.Details = new List<ApiDetailError>();
foreach (ValidationError v in errors)
{

View File

@@ -23,7 +23,7 @@ namespace AyaNova.Api.ControllerHelpers
//Generic error
public ApiNotAuthorizedResponse()
{
Error = new ApiError(ApiErrorCode.NOT_AUTHORIZED, ApiErrorCodeStockMessage.GetMessage(ApiErrorCode.NOT_AUTHORIZED));
Error = new ApiError(ApiErrorCode.NOT_AUTHORIZED, ApiErrorCodeStockMessage.GetTranslationCodeForApiErrorCode(ApiErrorCode.NOT_AUTHORIZED));
log.LogDebug("ApiErrorCode={0}, message={1}", (int)ApiErrorCode.NOT_AUTHORIZED, Error.Message);
}