diff --git a/src/api/artiste/controllers/artiste.js b/src/api/artiste/controllers/artiste.js index 0afa557..20b0db8 100644 --- a/src/api/artiste/controllers/artiste.js +++ b/src/api/artiste/controllers/artiste.js @@ -1,7 +1,6 @@ 'use strict'; const { createCoreController } = require('@strapi/strapi').factories; -const { ValidationError } = require("@strapi/utils").errors const slugify = require('slugify') const getSlug = text => { @@ -34,7 +33,7 @@ module.exports = createCoreController('api::artiste.artiste', ({strapi}) => ({ } if (user.id !== data.user.id || user.username !== data.user.username || user.email !== data.user.email) { - throw new ValidationError('Informations non valides.') + ctx.badRequest('Informations non valides.') } const artiste = await strapi.db.query('api::artiste.artiste').findOne({ diff --git a/src/api/parole/controllers/parole.js b/src/api/parole/controllers/parole.js index 17e8d17..649d236 100644 --- a/src/api/parole/controllers/parole.js +++ b/src/api/parole/controllers/parole.js @@ -34,27 +34,27 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({ ].services.jwt.getToken(ctx) if (id !== data.user.id) { - throw new UnauthorizedError('Opération non autorisée') + ctx.unauthorized('Opération non autorisée') } } catch (err) { - throw new UnauthorizedError(ctx, err, 'Opération non autorisée') + ctx.unauthorized(ctx, err, 'Opération non autorisée') } } const user = await strapi.entityService.findOne('plugin::users-permissions.user', body.data.user.id) if (!user) { - throw new NotFoundError('Utilisateur introuvable.') + ctx.notFound('Utilisateur introuvable.') } if (user.id !== data.user.id || user.username !== data.user.username || user.email !== data.user.email) { - throw new ValidationError('Informations non valides.') + ctx.badRequest('Informations non valides.') } const artiste = await strapi.entityService.findOne('api::artiste.artiste', data.artistes[0]) if (!artiste) { - throw new NotFoundError('Artiste introuvable.') + ctx.notFound('Artiste introuvable.') } const currentUserParole = await strapi.entityService.findMany('api::parole.parole', {