group photo upload: respond 500 on DB error instead of hanging (async throw in express4)
This commit is contained in:
@@ -826,7 +826,8 @@ app.post('/api/groups/:id/photos', requireAdmin, (req, res, next) => {
|
|||||||
res.status(201).json(rows[0]);
|
res.status(201).json(rows[0]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
safeUnlink(`uploads/${req.file.filename}`);
|
safeUnlink(`uploads/${req.file.filename}`);
|
||||||
throw e;
|
console.error('POST /api/groups/:id/photos:', e);
|
||||||
|
res.status(500).json({ error: e.message });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user