Replace ValidationError by ApplicationError in services & lifecycles

This commit is contained in:
2023-04-02 12:25:52 +04:00
parent a65b3f04e8
commit d61ef75869
5 changed files with 18 additions and 16 deletions
+4 -4
View File
@@ -4,7 +4,7 @@ const axios = require('axios')
const Diff = require('diff')
const { createCoreService } = require('@strapi/strapi').factories;
const { ValidationError } = require("@strapi/utils").errors
const { ApplicationError } = require("@strapi/utils").errors
class Translator {
constructor() {
@@ -56,15 +56,15 @@ module.exports = createCoreService('api::parole.parole', ({strapi}) => ({
},
validateParoles(titre, transcription) {
if (!titre || titre.trim().length === 0) {
throw new ValidationError('Champ obligatoire. Veuillez choisir un titre.');
throw new ApplicationError('Champ obligatoire. Veuillez choisir un titre.');
}
if (!transcription || transcription.trim().length === 0) {
throw new ValidationError('Champ obligatoire. Veuillez renseigner la transcription.')
throw new ApplicationError('Champ obligatoire. Veuillez renseigner la transcription.')
}
if (transcription.trim().length < 10) {
throw new ValidationError('La transcription doit contenir au moins 10 caractères.')
throw new ApplicationError('La transcription doit contenir au moins 10 caractères.')
}
},
parolesDiff(titre = '', oldString, newString) {