From 815b6f4c2ff5c07f39f4cb229e71ce463c560dfa Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 24 Oct 2018 10:10:35 +1300 Subject: [PATCH] If null is unexpected, throw error to more accurately inform player of malformed parameters --- .../disguise/utilities/parser/params/ParamInfo.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/parser/params/ParamInfo.java b/src/main/java/me/libraryaddict/disguise/utilities/parser/params/ParamInfo.java index 8323fad3..40971b2e 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/parser/params/ParamInfo.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/parser/params/ParamInfo.java @@ -47,12 +47,12 @@ public abstract class ParamInfo { } } - public ParamInfo(Class paramClass, String name, String description, Map possibleValues) { + public ParamInfo(Class paramClass, String name, String description, Map possibleValues) { this(paramClass, name, name, description, possibleValues); } public ParamInfo(Class paramClass, String name, String descriptiveName, String description, - Map possibleValues) { + Map 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;