6995-testToMaster_2410 #2139

Merged
alexm merged 236 commits from 6995-testToMaster_2410 into master 2024-03-07 07:09:08 +00:00
1 changed files with 5 additions and 23 deletions
Showing only changes of commit 62ccbb3074 - Show all commits

View File

@ -1,14 +1,7 @@
const SalixError = require('vn-loopback/util/salixError');
const UserError = require('vn-loopback/util/user-error');
const SalixError = require('../../util/salixError');
const UserError = require('../../util/user-error');
const logToConsole = require('strong-error-handler/lib/logger');
const valueIsNot = require('./value-is-not');
const valueInvalid = require('./value-invalid');
const mapMethods = require('vn-loopback/util/map-methods');
const validations = [
valueIsNot,
valueInvalid,
mapMethods
];
module.exports = function() {
return function(err, req, res, next) {
// Thrown user errors
@ -18,19 +11,7 @@ module.exports = function() {
}
// Validation errors
if ([400, 422].includes(err.statusCode)) {
try {
validations.forEach(validation => {
if (validation.validation(err.message)) {
const error = validation.handleError(req, err);
if (error)
err.message = validation.message(error, req);
}
});
return next(err);
} catch (e) {
}
if (err.statusCode == 422) {
try {
let code;
let {messages} = err.details;
@ -45,6 +26,7 @@ module.exports = function() {
return next(new UserError(req.__(err.sqlMessage)));
// Logs error to console
let env = process.env.NODE_ENV;
let useCustomLogging = env && env != 'development' &&
(!err.statusCode || err.statusCode >= 500);