From a016d6647436dba71420a5714e82467af6ba8db4 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 3 Feb 2022 22:01:31 +0100 Subject: [PATCH] throw instead of next --- backend/api/controllers/user.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/api/controllers/user.js b/backend/api/controllers/user.js index 05706e35b..20ec394f7 100644 --- a/backend/api/controllers/user.js +++ b/backend/api/controllers/user.js @@ -58,11 +58,10 @@ class UserController { static async checkName(req, res) { const { name } = req.body; if (!isUsernameValid(name)) - return next({ - status: 400, - message: - "Username invalid. Name cannot contain special characters or contain more than 14 characters. Can include _ . and -", - }); + throw new MonkeyError( + 400, + "Username invalid. Name cannot contain special characters or contain more than 14 characters. Can include _ . and -" + ); const available = await UsersDAO.isNameAvailable(name); if (!available) return res.status(400).json({ message: "Username unavailable" });