From 52f58a92c85f78d978bec7304816bef5b55c2d2f Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 17 Jul 2023 14:11:05 +0200 Subject: [PATCH] refs err.sqlMessage --- modules/invoiceIn/back/models/invoice-in.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 0efa6c309..82e0bf078 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -10,8 +10,7 @@ module.exports = Self => { require('../methods/invoice-in/invoiceInEmail')(Self); require('../methods/invoice-in/getSerial')(Self); Self.rewriteDbError(function(err) { - console.log(err); - if (err.code === 'ER_ROW_IS_REFERENCED_2') + if (err.code === 'ER_ROW_IS_REFERENCED_2' && err.sqlMessage.includes('vehicleInvoiceIn')) return new UserError(`This invoice has a linked vehicle.`); return err; });