Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 5005b05d authored by Jelizaveta Zaharova's avatar Jelizaveta Zaharova
Browse files

Adjusted logs

parent 4520149e
Branches
No related tags found
No related merge requests found
......@@ -97,12 +97,12 @@ namespace Tilde.MT.WebsiteTranslationService.Controllers
}
catch (InvalidTranslationException ex)
{
_logger.LogError("Translation is not valid");
_logger.LogError("Translation is not valid, please provide a correct translation");
return FormatAPIError(HttpStatusCode.BadRequest, Enums.ApiErrorCode.TranslationIsNotValid);
}
catch (ResourceNotFoundException ex)
{
_logger.LogError(ex, "Resource not found");
_logger.LogError(ex, "Cannot add new translation. Please provide existing target language and exisitng segment unique identifier");
return FormatAPIError(HttpStatusCode.NotFound, Enums.ApiErrorCode.ResourceNotFound);
}
}
......@@ -154,7 +154,7 @@ namespace Tilde.MT.WebsiteTranslationService.Controllers
}
catch (ResourceNotFoundException ex)
{
_logger.LogError(ex, "Resource not found");
_logger.LogError(ex, "Translation cannot be accepted, because resource is not found. Please provide existing target language and exisitng segment unique identifier");
return FormatAPIError(HttpStatusCode.NotFound, ApiErrorCode.ResourceNotFound);
}
}
......@@ -186,12 +186,12 @@ namespace Tilde.MT.WebsiteTranslationService.Controllers
}
catch (ResourceNotFoundException ex)
{
_logger.LogError(ex, "Resource not found");
_logger.LogError(ex, "Translation is not found, please provide correct website unique identifier, segment unique identifier, target language, and translation unique identifier");
return FormatAPIError(HttpStatusCode.NotFound, ApiErrorCode.ResourceNotFound);
}
catch (AcceptedTranslationDeleteNotAllowedException ex)
{
_logger.LogError(ex, "Cannot delete accepted translation");
_logger.LogError(ex, "Cannot delete translation because it is accepted");
return FormatAPIError(HttpStatusCode.BadRequest, ApiErrorCode.CannotDeleteAcceptedTranslation);
}
}
......
......@@ -4,7 +4,6 @@ using Swashbuckle.AspNetCore.Annotations;
using System.Net;
using Tilde.EMW.Contracts.Exceptions.TranslationSystem;
using Tilde.EMW.Contracts.Models.Common.Errors;
using Tilde.MT.WebsiteTranslationService.Exceptions;
using Tilde.MT.WebsiteTranslationService.Exceptions.Domain;
using Tilde.MT.WebsiteTranslationService.Interfaces.Services;
......@@ -61,14 +60,9 @@ namespace Tilde.MT.WebsiteTranslationService.Controllers
_logger.LogError("Translation timeout: {Error}", ex.Message);
return FormatAPIError(HttpStatusCode.GatewayTimeout, Enums.ApiErrorCode.TranslationTimeout);
}
catch (ResourceNotFoundException ex)
{
_logger.LogError(ex, "Resource not found");
return FormatAPIError(HttpStatusCode.NotFound, Enums.ApiErrorCode.ResourceNotFound);
}
catch (DomainNotAllowedException ex)
{
_logger.LogError(ex, "Domain not allowed");
_logger.LogError(ex, "Domain '{Referer}' not allowed for website '{websiteId}'", header.Referer?.DnsSafeHost, websiteId);
return FormatAPIError(HttpStatusCode.BadRequest, Enums.ApiErrorCode.DomainNotAllowed);
}
}
......
using Microsoft.EntityFrameworkCore;
using Tilde.EMW.Contracts.Exceptions.TranslationSystem;
using Tilde.MT.WebsiteTranslationService.Enums.Segment;
using Tilde.MT.WebsiteTranslationService.Exceptions;
using Tilde.MT.WebsiteTranslationService.Exceptions.Domain;
using Tilde.MT.WebsiteTranslationService.Interfaces.Providers;
using Tilde.MT.WebsiteTranslationService.Interfaces.Services;
......@@ -95,7 +95,7 @@ namespace Tilde.MT.WebsiteTranslationService.Services
if (languageDirection == null)
{
throw new ResourceNotFoundException();
throw new LanguageDirectionNotFoundException(request.TargetLanguage);
}
var cachedSegmentTranslations = await _dbContext.SegmentTranslations
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment