IDEMPIERE-5366 Better error reporting on Pack In failure (#1422)

[pipo] Throw useful exception when table not found
With this commit, Pack In will throw an informative error message
if it can't find a table (including the table name). Without
this fix, you simply get an NPE which doesn't help with debugging.

IDEMPIERE-5366 #resolve
This commit is contained in:
Fr Jeremy Krieg 2022-08-04 18:35:32 +09:30 committed by GitHub
parent 27c5d0fa53
commit 00daca9c94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -48,6 +48,9 @@ public class POFinder {
if (AD_Client_ID==0)
return uuid;
MTable table = MTable.get(ctx, tableName);
if (table == null) {
throw new IllegalStateException("getTargetUUID couldn't find table named " + tableName);
}
String sql = "SELECT Target_UUID FROM AD_Package_UUID_Map WHERE AD_Client_ID=? AND AD_Table_ID=? AND Source_UUID=?";
String uid = DB.getSQLValueString(trxName, sql, AD_Client_ID, table.getAD_Table_ID(), uuid);
return Util.isEmpty(uid) ? uuid : uid;