diff --git a/ValgrindCI/render.py b/ValgrindCI/render.py index 2c943e5..62cb884 100644 --- a/ValgrindCI/render.py +++ b/ValgrindCI/render.py @@ -124,10 +124,13 @@ def _extract_error_data( stack["fileref"] = "{}:{}".format( frame.get_path(self._source_dir), error_line ) - with open(fullname, "r") as f: - for l, code_line in enumerate(f.readlines()): - if l >= stack["line"] and l <= error_line + lines_after - 1: - stack["code"].append(code_line) + try: + with open(fullname, "r") as f: + for l, code_line in enumerate(f.readlines()): + if l >= stack["line"] and l <= error_line + lines_after - 1: + stack["code"].append(code_line) + except FileNotFoundError: + stack["code"].append("/* Source file not available or could not be opened. */") issue["stack"].append(stack) return issue