⬆️ Upgrade kotlinx-html
[rhynodge.git] / src / main / java / net / pterodactylus / util / envopt / Parser.java
index 208d6f4..dc619ea 100644 (file)
@@ -29,11 +29,11 @@ public class Parser {
                                String variableName = option.name();
                                Optional<String> value = environment.getValue(variableName);
                                if (option.required() && !value.isPresent()) {
-                                       throw new RequiredOptionIsMissing();
+                                       throw new RequiredOptionIsMissing(option.name());
                                }
                                field.setAccessible(true);
                                try {
-                                       field.set(optionsObject, value.orElse(null));
+                                       field.set(optionsObject, value.orElse(option.defaultValue()));
                                } catch (IllegalAccessException iae1) {
                                        /* swallow. */
                                }
@@ -46,6 +46,12 @@ public class Parser {
                return new Parser(new SystemEnvironment());
        }
 
-       public static class RequiredOptionIsMissing extends RuntimeException { }
+       public static class RequiredOptionIsMissing extends RuntimeException {
+
+               public RequiredOptionIsMissing(String message) {
+                       super(message);
+               }
+
+       }
 
 }