From 23f464557becdca7b67a15fa74fa89ad6846a6a1 Mon Sep 17 00:00:00 2001 From: Jose Leite <122051639+joseleite550@users.noreply.github.com> Date: Wed, 11 Oct 2023 07:37:31 -0300 Subject: [PATCH] IDEMPIERE-5872 - Improve on SQL Errors displayed for user (#2033) * IDEMPIERE-5872 - Improve on SQL Errors displayed for user * IDEMPIERE-5872 - Improve on SQL Errors displayed for user --- org.adempiere.base/src/org/compiere/acct/Doc.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/acct/Doc.java b/org.adempiere.base/src/org/compiere/acct/Doc.java index 456d6cc885..aa9deefa5e 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc.java @@ -30,6 +30,7 @@ import java.util.Iterator; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.exceptions.DBException; import org.compiere.model.I_C_AllocationHdr; import org.compiere.model.I_C_Cash; import org.compiere.model.I_C_ProjectIssue; @@ -312,6 +313,11 @@ public abstract class Doc catch (Throwable t) { trx.rollback(); + if(t instanceof SQLException sqlEx) { + String messageError = DBException.getDefaultDBExceptionMessage(sqlEx); + if (messageError != null) + return Msg.getMsg(Env.getCtx(), messageError); + } return "@Error@ " + t.getLocalizedMessage(); } finally