Better exception message on not found field

This commit is contained in:
Francesco 2023-11-07 22:45:46 +01:00
parent 95b9104295
commit f1b0f166b1
2 changed files with 10 additions and 2 deletions

View File

@ -49,6 +49,7 @@ import tech.ailef.snapadmin.external.annotations.HiddenColumn;
import tech.ailef.snapadmin.external.dbmapping.fields.DbField; import tech.ailef.snapadmin.external.dbmapping.fields.DbField;
import tech.ailef.snapadmin.external.dto.MappingError; import tech.ailef.snapadmin.external.dto.MappingError;
import tech.ailef.snapadmin.external.exceptions.SnapAdminException; import tech.ailef.snapadmin.external.exceptions.SnapAdminException;
import tech.ailef.snapadmin.external.exceptions.SnapAdminNotFoundException;
import tech.ailef.snapadmin.external.misc.Utils; import tech.ailef.snapadmin.external.misc.Utils;
/** /**
@ -375,9 +376,15 @@ public class DbObjectSchema {
for (String param : params.keySet()) { for (String param : params.keySet()) {
// Parameters starting with __ are hidden and not related to the object creation // Parameters starting with __ are hidden and not related to the object creation
if (param.startsWith("__")) continue; if (param.startsWith("__")
|| param.equals("_csrf")) continue;
String javaFieldName = getFieldByName(param).getJavaName(); DbField dbField = getFieldByName(param);
if (dbField == null)
throw new SnapAdminNotFoundException("Cannot find field " + param + " in " + getJavaClass().getName());
String javaFieldName = dbField.getJavaName();
Method setter = dbObject.findSetter(javaFieldName); Method setter = dbObject.findSetter(javaFieldName);
if (setter == null) { if (setter == null) {

View File

@ -161,4 +161,5 @@ public class UserAction {
this.username = username; this.username = username;
} }
} }