Mongoose 4.x (#9928)

* update mongoose to ^4.x

* another fix
This commit is contained in:
Matteo Pagliazzi
2018-02-02 16:37:36 +01:00
committed by GitHub
parent 389d6f18b4
commit 1fbdb7dbd0
8 changed files with 531 additions and 340 deletions

View File

@@ -39,7 +39,8 @@ module.exports = function errorHandler (err, req, res, next) { // eslint-disable
// Handle mongoose validation errors
if (err.name === 'ValidationError') {
responseErr = new BadRequest(err.message); // TODO standard message? translate?
const model = err.message.split(' ')[0];
responseErr = new BadRequest(`${model} validation failed`);
responseErr.errors = map(err.errors, (mongooseErr) => {
return {
message: mongooseErr.message,