Skip to content

Commit fd5b9c0

Browse files
committed
Better goto-instrument error reporting for missing files
In the past, goto-instrument was failing with the default --help error message if it didn't get the correct number of positional arguments, making it unnecessarily hard to understand what was failing and why (since the help message is long and it also didn't have any particular signaling for what went wrong). This makes it so that it reports it as an invalid user input exception. Fixes diffblue#2861.
1 parent 99aabb4 commit fd5b9c0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]
1616
#include <memory>
1717

1818
#include <util/config.h>
19+
#include <util/exception_utils.h>
1920
#include <util/exit_codes.h>
2021
#include <util/json.h>
2122
#include <util/string2int.h>
@@ -824,6 +825,14 @@ int goto_instrument_parse_optionst::doit()
824825
else
825826
return CPROVER_EXIT_SUCCESS;
826827
}
828+
else if(cmdline.args.size() < 2)
829+
{
830+
throw invalid_command_line_argument_exceptiont(
831+
"Invalid number of positional arguments passed",
832+
"[in] [out]",
833+
"goto-instrument needs one input and one output file, aside from other "
834+
"flags");
835+
}
827836

828837
help();
829838
return CPROVER_EXIT_USAGE_ERROR;

0 commit comments

Comments
 (0)