From cca62ae90242766767c64f18df758d2b9b45385f Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 26 Jun 2024 12:25:18 +0200 Subject: [PATCH] feat: return sql check error --- loopback/locale/es.json | 3 ++- loopback/server/middleware/error-handler.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 5b5928993..e2be5d013 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -366,5 +366,6 @@ "It has been invoiced but the PDF could not be generated": "Se ha facturado pero no se ha podido generar el PDF", "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono", "Payment method is required": "El método de pago es obligatorio", - "Cannot send mail": "Não é possível enviar o email" + "Cannot send mail": "Não é possível enviar o email", + "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos" } diff --git a/loopback/server/middleware/error-handler.js b/loopback/server/middleware/error-handler.js index cc7b81618..beeff95ae 100644 --- a/loopback/server/middleware/error-handler.js +++ b/loopback/server/middleware/error-handler.js @@ -22,7 +22,7 @@ module.exports = function() { } // MySQL user-defined exceptions - if (err.sqlState == '45000') + if (err.sqlState == '45000' || err?.errno == 4025) return next(new UserError(req.__(err.sqlMessage))); // Logs error to console