Skip to content

Commit 0d054e2

Browse files
slarenprusnak
authored andcommitted
Show error message when -f fails
1 parent 3525899 commit 0d054e2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/common.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
6666
break;
6767
}
6868
std::ifstream file(argv[i]);
69+
if (!file) {
70+
fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
71+
invalid_param = true;
72+
break;
73+
}
6974
std::copy(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), back_inserter(params.prompt));
7075
if (params.prompt.back() == '\n') {
7176
params.prompt.pop_back();

0 commit comments

Comments
 (0)