Skip to content

Commit 9085e79

Browse files
committed
Log an error instead of throwing an IllegalArgumentException (since it isn't captured in server logs). Improve error messages by including the source trigger script name as a parameter.
1 parent 21917bc commit 9085e79

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

LDK/src/org/labkey/ldk/query/LookupValidationHelper.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ public void cascadeUpdate(String targetSchema, String targetTable, String target
193193
qus.updateRows(_user, _container, toUpdate, oldPKs, null, new HashMap<>());
194194
}
195195

196-
public boolean verifyNotUsed(String targetSchema, String targetTable, String targetField, Object val) throws SQLException
196+
public boolean verifyNotUsed(String targetSchema, String targetTable, String targetField, Object val, String triggerScriptName) throws SQLException
197197
{
198-
return verifyNotUsed(targetSchema, targetTable, targetField, val, null);
198+
return verifyNotUsed(targetSchema, targetTable, targetField, val, null, triggerScriptName);
199199
}
200200

201-
public boolean verifyNotUsed(String targetSchema, String targetTable, String targetField, Object val, @Nullable String containerPath) throws SQLException
201+
public boolean verifyNotUsed(String targetSchema, String targetTable, String targetField, Object val, @Nullable String containerPath, String triggerScriptName) throws SQLException
202202
{
203203
Container c = _container;
204204
if (containerPath != null)
@@ -212,14 +212,23 @@ public boolean verifyNotUsed(String targetSchema, String targetTable, String tar
212212

213213
UserSchema us = QueryService.get().getUserSchema(_user, c, targetSchema);
214214
if (us == null)
215-
throw new IllegalArgumentException("Unknown schema: " + targetSchema);
215+
{
216+
_log.error("Error running '" + triggerScriptName + "' trigger script. Schema '{}' not found in container '{}'", targetSchema, c.getName());
217+
return false;
218+
}
216219

217220
TableInfo ti = us.getTable(targetTable);
218221
if (ti == null)
219-
throw new IllegalArgumentException("Unknown table: " + targetTable);
222+
{
223+
_log.error("Error running '" + triggerScriptName + "' trigger script. Table '{}' not found in container '{}'", targetTable, c.getName());
224+
return false;
225+
}
220226

221227
if (ti.getColumn(targetField) == null)
222-
throw new IllegalArgumentException("Unknown column: " + targetField + " in table: " + targetTable);
228+
{
229+
_log.error("Error running '" + triggerScriptName + "' trigger script. Column '{}' not found in table '{}'", targetField, targetTable);
230+
return false;
231+
}
223232

224233
TableSelector ts = new TableSelector(ti, new SimpleFilter(FieldKey.fromString(targetField), val), null);
225234

0 commit comments

Comments
 (0)