Code RoomError response format inconsistent
MediumPrep Room Coding #1981

Error response format inconsistent

Code reviewDatabases & SQLMid–Senior~20 min

Review these two TypeScript handlers from the same service. A client wants one error-handling code path for both.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1// POST /login
2app.post('/login', (req, res) => {
3 if (!valid(req.body)) {
4 return res.status(400).json({ error: 'invalid credentials' });
5 }
6 // ...
7});
8 
9// POST /orders
10app.post('/orders', (req, res) => {
11 if (!req.body.items?.length) {
12 return res.status(422).send('items required');
13 }
14 if (!authorized(req)) {
15 return res.json({ ok: false, message: 'forbidden', code: 1037 });
16 }
17 // ...
18});
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.