Skip to content

Commit

Permalink
Improve corrupted cache error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsauer committed Jul 6, 2022
1 parent cdaaef3 commit a17d898
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion refresh.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,12 @@ def _get_headers(compile_action, source_path: str):
action_key, headers = json.load(cache_file)
except json.JSONDecodeError:
# Corrupted cache, which can happen if, for example, the user kills the program, since writes aren't atomic.
# But if it is the result of a bug, we want to print it before it's overwritten, so it can be reported
# For a real instance, see https://github.com/hedronvision/bazel-compile-commands-extractor/issues/60
with open(cache_file_path) as cache_file:
print(f"""\033[0;33m>>> Ignoring corrupted header cache {cache_file_path}
This is okay if you manually killed this tool earlier.
But if this message is appearing spontaneously or frequently, please file an issue containing the contents of the corrupted cache, which we'll print below before the cache is overwritten.
But if this message is appearing spontaneously or frequently, please file an issue containing the contents of the corrupted cache, below.
{cache_file.read()}
Thanks for your help!
Continuing gracefully...\033[0m""", file=sys.stderr)
Expand Down

0 comments on commit a17d898

Please sign in to comment.