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
@@ -1,7 +1,7 @@
'use strict';
const { createCoreController } = require('@strapi/strapi').factories;
const { ValidationError, NotFoundError, UnauthorizedError } = require("@strapi/utils").errors
const { ApplicationError, NotFoundError, UnauthorizedError } = require("@strapi/utils").errors
module.exports = createCoreController('api::commentaire.commentaire', ({strapi}) => ({
async create(ctx) {
@@ -28,7 +28,7 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
}
if (user.id !== data.user.id || user.username !== data.user.username || user.email !== data.user.email) {
throw new ValidationError('Informations non valides.')
throw new ApplicationError('Informations non valides.')
}
data.user = user.id