Include name of missing option in exception
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 5 May 2015 20:12:29 +0000 (22:12 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 5 May 2015 20:12:29 +0000 (22:12 +0200)
src/main/java/net/pterodactylus/util/envopt/Parser.java

index 208d6f4..bc2d986 100644 (file)
@@ -29,7 +29,7 @@ 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 {
@@ -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);
+               }
+
+       }
 
 }