Catch exceptions when deleting wines from lottery.
This commit is contained in:
@@ -128,16 +128,24 @@ const deleteWineById = (req, res) => {
|
|||||||
const deleteWines = (req, res) => {
|
const deleteWines = (req, res) => {
|
||||||
return lotteryRepository
|
return lotteryRepository
|
||||||
.deleteWines()
|
.deleteWines()
|
||||||
.then(removedWine => {
|
.then(_ => {
|
||||||
var io = req.app.get("socketio");
|
var io = req.app.get("socketio");
|
||||||
io.emit("refresh_data", {});
|
io.emit("refresh_data", {});
|
||||||
})
|
})
|
||||||
.then(_ =>
|
.then(_ =>
|
||||||
res.send({
|
res.send({
|
||||||
message: "Removed all wines",
|
message: "Removed all wines.",
|
||||||
success: true
|
success: true
|
||||||
})
|
})
|
||||||
);
|
)
|
||||||
|
.catch(error => {
|
||||||
|
const { statusCode, message } = error;
|
||||||
|
|
||||||
|
return res.status(statusCode || 500).send({
|
||||||
|
message: message || "Unexpected error occured while deleting wines",
|
||||||
|
success: false
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
Reference in New Issue
Block a user