diff --git a/common/ngram-cache.cpp b/common/ngram-cache.cpp index a1309ee6e..1dcda9352 100644 --- a/common/ngram-cache.cpp +++ b/common/ngram-cache.cpp @@ -217,7 +217,7 @@ void llama_ngram_cache_save(llama_ngram_cache & ngram_cache, std::string & filen llama_ngram_cache llama_ngram_cache_load(std::string & filename) { std::ifstream hashmap_file(filename, std::ios::binary); if (!hashmap_file) { - throw std::system_error(); + throw std::ifstream::failure("Unable to open file " + filename); } llama_ngram_cache ngram_cache; diff --git a/examples/lookup/lookup-stats.cpp b/examples/lookup/lookup-stats.cpp index ce6a5186a..d58eec18c 100644 --- a/examples/lookup/lookup-stats.cpp +++ b/examples/lookup/lookup-stats.cpp @@ -52,7 +52,7 @@ int main(int argc, char ** argv){ if (!params.lookup_cache_static.empty()) { try { ngram_cache_static = llama_ngram_cache_load(params.lookup_cache_static); - } catch (std::system_error const &) { + } catch (std::ifstream::failure const &) { fprintf(stderr, "error: failed to open static lookup cache: %s", params.lookup_cache_static.c_str()); exit(1); } @@ -61,7 +61,7 @@ int main(int argc, char ** argv){ if (!params.lookup_cache_dynamic.empty()) { try { ngram_cache_dynamic = llama_ngram_cache_load(params.lookup_cache_dynamic); - } catch (std::system_error const &) {} // if the file does not exist it will simply be created at the end of the program + } catch (std::ifstream::failure const &) {} // if the file does not exist it will simply be created at the end of the program } t_draft_flat_us += ggml_time_us() - t_start_draft_us; diff --git a/examples/lookup/lookup.cpp b/examples/lookup/lookup.cpp index 00319c428..2e8c35de3 100644 --- a/examples/lookup/lookup.cpp +++ b/examples/lookup/lookup.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -63,7 +62,7 @@ int main(int argc, char ** argv){ if (!params.lookup_cache_static.empty()) { try { ngram_cache_static = llama_ngram_cache_load(params.lookup_cache_static); - } catch (std::system_error const &) { + } catch (std::ifstream::failure const &) { fprintf(stderr, "error: failed to open static lookup cache: %s", params.lookup_cache_static.c_str()); exit(1); } @@ -72,7 +71,7 @@ int main(int argc, char ** argv){ if (!params.lookup_cache_dynamic.empty()) { try { ngram_cache_dynamic = llama_ngram_cache_load(params.lookup_cache_dynamic); - } catch (std::system_error const &) {} // if the file does not exist it will simply be created at the end of the program + } catch (std::ifstream::failure const &) {} // if the file does not exist it will simply be created at the end of the program } t_draft_flat_us += ggml_time_us() - t_start_draft_us;