diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index f56183df2..cc3eede8e 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -145,9 +145,15 @@ module.exports = function(Self) { rewriteDbError(replaceErrFunc) { function replaceErr(err, replaceErrFunc) { if (Array.isArray(err)) { + const errors = err.filter(error => { + return error != undefined && error != null; + }); let errs = []; - for (let e of err) - errs.push(replaceErrFunc(e)); + for (let e of errors) { + if (!(e instanceof UserError)) + errs.push(replaceErrFunc(e)); + else errs.push(e); + } return errs; } return replaceErrFunc(err);