diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index ef7f0b204c..012f72b08a 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -2266,7 +2266,8 @@ public abstract class PO msg = (val != null ? val + ": " : "") + err.getName(); if (msg == null || msg.length() == 0) msg = "SaveError"; - throw new AdempiereException(msg); + Exception ex = CLogger.retrieveException(); + throw new AdempiereException(msg, ex); } } @@ -3558,7 +3559,8 @@ public abstract class PO msg = err.getName(); if (msg == null || msg.length() == 0) msg = "DeleteError"; - throw new AdempiereException(msg); + Exception ex = CLogger.retrieveException(); + throw new AdempiereException(msg, ex); } } @@ -4841,7 +4843,7 @@ public abstract class PO if ("DBExecuteError".equals(msg)) info = "DBExecuteError:" + info; // Unique Constraint - Exception e = CLogger.retrieveException(); + Exception e = CLogger.peekException(); if (DBException.isUniqueContraintError(e)) { boolean found = false; diff --git a/org.adempiere.base/src/org/compiere/util/CLogger.java b/org.adempiere.base/src/org/compiere/util/CLogger.java index a9e2278da9..90ed937d48 100644 --- a/org.adempiere.base/src/org/compiere/util/CLogger.java +++ b/org.adempiere.base/src/org/compiere/util/CLogger.java @@ -199,7 +199,7 @@ public class CLogger extends Logger { ValueNamePair vp = (ValueNamePair) Env.getCtx().get(LAST_ERROR); return vp; - } // retrieveError + } // peekError /** * Get Error message from stack @@ -225,6 +225,16 @@ public class CLogger extends Logger return ex; } // retrieveError + /** + * Peek Exception from Stack + * @return last exception + */ + public static Exception peekException() + { + Exception ex = (Exception) Env.getCtx().get(LAST_EXCEPTION); + return ex; + } // peekException + /** * Save Warning as ValueNamePair. * @param AD_Message message key