You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am struggling to handle error with bookshelf.
I have a controller wich handle the CRUD like this for the GET :
req.models[model].findById(req.params.id)
.then(user => {
res.status(200).send(user);
}).catch(req.models[model].NotFoundError, () => {
throw new ApiError("NOT_FOUND", `No ${model} found for id ${req.params.id}.`, 404);
}).catch(err => {
next(err)
});
It works perfectly fine.
But for the deletion or update:
req.models[model].delete(req.params.id)
.then(() => {
return res.status(204).send();
})
.catch(req.models[model].NoRowsDeletedError, () => {
throw new ApiError("NOT_FOUND", `No ${model} found for id ${req.params.id}.`, 404);
})
It is not working at all. It is specified in the doc that if no ID exist for a deletion it should return a 'NoRowsDeletedError' here (since the 0.13, and I am in 1.2)
Instead Booshelf make the lib create-error in crash with this message: Cannot set property 'message' of undefined
because I think the error from Bookshelf is not in a good format [Arguments] { '0': 'No Rows Deleted' }
I do not know what to do or if I am doing something wrong.
Thanks for the help
The text was updated successfully, but these errors were encountered:
Hi everyone.
I am struggling to handle error with bookshelf.
I have a controller wich handle the CRUD like this for the GET :
It works perfectly fine.
But for the deletion or update:
It is not working at all. It is specified in the doc that if no ID exist for a deletion it should return a 'NoRowsDeletedError' here (since the 0.13, and I am in 1.2)
Instead Booshelf make the lib create-error in crash with this message:
Cannot set property 'message' of undefined
because I think the error from Bookshelf is not in a good format
[Arguments] { '0': 'No Rows Deleted' }
I do not know what to do or if I am doing something wrong.
Thanks for the help
The text was updated successfully, but these errors were encountered: