fix(shell/lean): catch errors when loading bad cache file
This commit is contained in:
parent
30817aa2b1
commit
ddcc8de09e
1 changed files with 10 additions and 4 deletions
|
@ -483,10 +483,16 @@ int main(int argc, char ** argv) {
|
|||
definition_cache cache;
|
||||
definition_cache * cache_ptr = nullptr;
|
||||
if (use_cache) {
|
||||
cache_ptr = &cache;
|
||||
std::ifstream in(cache_name, std::ifstream::binary);
|
||||
if (!in.bad() && !in.fail())
|
||||
cache.load(in);
|
||||
try {
|
||||
cache_ptr = &cache;
|
||||
std::ifstream in(cache_name, std::ifstream::binary);
|
||||
if (!in.bad() && !in.fail())
|
||||
cache.load(in);
|
||||
} catch (lean::throwable & ex) {
|
||||
lean::display_error(diagnostic(env, ios), nullptr, ex);
|
||||
std::cerr << "Failed to load cache file '" << cache_name << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
declaration_index index;
|
||||
declaration_index * index_ptr = nullptr;
|
||||
|
|
Loading…
Reference in a new issue