1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

fix: Name conflict should return 409

closes #509
This commit is contained in:
Ivar Conradi Østhus 2020-09-25 22:14:31 +02:00
parent 2ce9b4e0c3
commit 1e26c64912

View File

@ -26,13 +26,17 @@ const nameType = customJoi
const handleErrors = (res, logger, error) => { const handleErrors = (res, logger, error) => {
logger.warn(error.message); logger.warn(error.message);
// eslint-disable-next-line no-param-reassign
error.isJoi = true;
switch (error.name) { switch (error.name) {
case 'NotFoundError': case 'NotFoundError':
return res.status(404).end(); return res.status(404).end();
case 'NameExistsError': case 'NameExistsError':
return res
.status(409)
.json(error)
.end();
case 'ValidationError': case 'ValidationError':
// eslint-disable-next-line no-param-reassign
error.isJoi = true;
return res return res
.status(400) .status(400)
.json(error) .json(error)