aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlaren <2141330+slaren@users.noreply.github.com>2023-03-31 20:03:48 +0200
committerPavol Rusnak <pavol@rusnak.io>2023-04-01 16:08:40 +0200
commit0d054e292e5492981867be69c788edd04dc8adeb (patch)
tree600d5d1de8a31496829cb59345ddadea6f57012c
parent3525899277d2e2bdc8ec3f0e6e40c47251608700 (diff)
Show error message when -f fails
-rw-r--r--examples/common.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/common.cpp b/examples/common.cpp
index af3ad9e..50c5365 100644
--- a/examples/common.cpp
+++ b/examples/common.cpp
@@ -66,6 +66,11 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
break;
}
std::ifstream file(argv[i]);
+ if (!file) {
+ fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
+ invalid_param = true;
+ break;
+ }
std::copy(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), back_inserter(params.prompt));
if (params.prompt.back() == '\n') {
params.prompt.pop_back();