From 027339d20f8d56186b844f56b76130445fd3858f Mon Sep 17 00:00:00 2001 From: Laurens Kling Date: Wed, 19 Dec 2018 02:35:57 +0100 Subject: [PATCH] Return a 500 error when `item.remove` fails (#4832) * Return a 500 error when `item.remove` fails Currently, errors from `item.remove` are not handled at all in the callback. This gives an empty 200 back to the frontend, which will do nothing with this response (no visual feedback on the error). We should return an actual error. All suggestions on how to return this error Keystone style are welcome. * directly send the `err` to `apiError` --- admin/server/api/list/delete.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/server/api/list/delete.js b/admin/server/api/list/delete.js index 53a966d1af..0a9ad19ede 100644 --- a/admin/server/api/list/delete.js +++ b/admin/server/api/list/delete.js @@ -44,7 +44,8 @@ module.exports = function (req, res) { deletedIds.push(item.id); next(); }); - }, function () { + }, function (err) { + if (err) return res.apiError(err); return res.json({ success: true, ids: deletedIds,