diff --git a/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandler.java b/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandler.java index e8526378..ac29525c 100644 --- a/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandler.java +++ b/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandler.java @@ -144,7 +144,7 @@ public void loadArgProgramPaths(){ String applicationSourceDirectory = Config.getApplicationSourceDirectoryPathString(); if(options.isEmpty()){ // return error when no program is passed - throw new PossibleInternalLogicErrorException(Messages.get("ERR005")); + throw new CommandLineArgumentException(Messages.get("ERR030")); } for (OptionKey optionKey : options.keySet()) { if (optionKey.shortKey.equals(Constants.PROGRAMS_OPTION) || optionKey.longKey.equals(Constants.PROGRAMS_OPTION)) { diff --git a/src/main/resources/org/openmainframeproject/cobolcheck/messages/messages.properties b/src/main/resources/org/openmainframeproject/cobolcheck/messages/messages.properties index c5c2046c..a3597639 100644 --- a/src/main/resources/org/openmainframeproject/cobolcheck/messages/messages.properties +++ b/src/main/resources/org/openmainframeproject/cobolcheck/messages/messages.properties @@ -30,6 +30,9 @@ ERR027 = ERR027: NumericFields.dataTypeOf() was called with empty fieldName. ERR028 = ERR028: NumericFields.setDataTypeOf() was called with empty fieldName. ERR029 = ERR029: NumericFields.setDataTypeOf() was called with null dataType. +ERR030 = ERR030: Command line missing program argument. + + WRN001 = WRN001: No test suite directory for program %1$s was found under directory %2$s. WRN002 = WRN002: No test suite files were found under directory %1$s. WRN003 = WRN003: DirectoryNameMatcher caught IOException on file %1$s. diff --git a/src/test/java/org/openmainframeproject/cobolcheck/ArgumentHandlerTest.java b/src/test/java/org/openmainframeproject/cobolcheck/ArgumentHandlerTest.java index 75f2ef5b..354bcf97 100644 --- a/src/test/java/org/openmainframeproject/cobolcheck/ArgumentHandlerTest.java +++ b/src/test/java/org/openmainframeproject/cobolcheck/ArgumentHandlerTest.java @@ -133,4 +133,15 @@ public void it_throws_when_no_value_is_passed_for_the_last_argument_and_it_requi }); } + @Test + public void it_throws_when_program_argument_is_not_present() { + Throwable ex = assertThrows(CommandLineArgumentException.class, () -> { + ArgumentHandler argumentHandler = new ArgumentHandler(new String[] { }, + optionSpec); + argumentHandler.loadArgProgramPaths(); + }); + assertEquals("ERR030: Command line missing program argument.", + ex.getMessage()); + } + }