ソースを参照

Throw accoutn does not exist error if account does not exist

sbkwgh 8 年 前
コミット
b3839bc591
1 ファイル変更11 行追加4 行削除
  1. 11 4
      routes/user.js

+ 11 - 4
routes/user.js

@@ -124,12 +124,19 @@ router.get('/:username', async (req, res) => {
 			where: { username: req.params.username }
 		})
 
+		if(!user) throw Errors.accountDoesNotExist
+
 		res.json(user.toJSON())
 	} catch (err) {
-		res.status(500)
-		res.json({
-			errors: [Errors.unknown]
-		})
+		if(err === Errors.accountDoesNotExist) {
+			res.status(400)
+			res.json({ errors: [err] })
+		} else {
+			res.status(500)
+			res.json({
+				errors: [Errors.unknown]
+			})
+		}
 	}
 })