If null is unexpected, throw error to more accurately inform player of malformed parameters
This commit is contained in:
parent
4467075a35
commit
815b6f4c2f
@ -47,12 +47,12 @@ public abstract class ParamInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public ParamInfo(Class paramClass, String name, String description, Map<String,Object> possibleValues) {
|
||||
public ParamInfo(Class paramClass, String name, String description, Map<String, Object> possibleValues) {
|
||||
this(paramClass, name, name, description, possibleValues);
|
||||
}
|
||||
|
||||
public ParamInfo(Class paramClass, String name, String descriptiveName, String description,
|
||||
Map<String,Object> possibleValues) {
|
||||
Map<String, Object> possibleValues) {
|
||||
this(paramClass, name, descriptiveName, description);
|
||||
|
||||
this.possibleValues = new HashMap<>();
|
||||
@ -83,6 +83,11 @@ public abstract class ParamInfo {
|
||||
|
||||
Object value = fromString(string);
|
||||
|
||||
// Throw error if null wasn't expected
|
||||
if (value == null && !canReturnNull()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
arguments.remove(0);
|
||||
|
||||
return value;
|
||||
|
Loading…
Reference in New Issue
Block a user