From 0d054e292e5492981867be69c788edd04dc8adeb Mon Sep 17 00:00:00 2001 From: Slaren <2141330+slaren@users.noreply.github.com> Date: Fri, 31 Mar 2023 20:03:48 +0200 Subject: [PATCH] Show error message when -f fails --- examples/common.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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(file), std::istreambuf_iterator(), back_inserter(params.prompt)); if (params.prompt.back() == '\n') { params.prompt.pop_back();