IDEMPIERE-4217 Improve DB exception traceability in PO saveEx and deleteEx (FHEG-1684)

This commit is contained in:
Carlos Ruiz 2020-03-21 17:44:26 +01:00
parent 3efc30368b
commit 43d77dee4e
2 changed files with 16 additions and 4 deletions

View File

@ -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;

View File

@ -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