mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-10 21:53:13 +08:00
throw instead of next
This commit is contained in:
parent
2fdf28fcf3
commit
a016d66474
1 changed files with 4 additions and 5 deletions
|
@ -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" });
|
||||
|
|
Loading…
Reference in a new issue