mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
parent
2ce9b4e0c3
commit
1e26c64912
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user