From ed80e9357a033a5823653998b67d3cdb219c8a69 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 13 Jun 2024 22:37:00 -0700 Subject: [PATCH] LogReader: improve error messages (#32747) * better error messages * clean up old-commit-hash: 3ede1e2a7c850622beef2549315f320aa018105a --- tools/lib/logreader.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/lib/logreader.py b/tools/lib/logreader.py index 2430f1542c..737ef46152 100755 --- a/tools/lib/logreader.py +++ b/tools/lib/logreader.py @@ -166,7 +166,8 @@ def get_invalid_files(files): def check_source(source: Source, *args) -> LogPaths: files = source(*args) - assert next(get_invalid_files(files), False) is False + assert len(files) > 0, "No files on source" + assert not any(get_invalid_files(files)), f"Invalid files: {files}" return files @@ -175,7 +176,7 @@ def auto_source(sr: SegmentRange, mode=ReadMode.RLOG) -> LogPaths: return comma_car_segments_source(sr, mode) SOURCES: list[Source] = [internal_source, openpilotci_source, comma_api_source, comma_car_segments_source,] - exceptions = [] + exceptions = {} # for automatic fallback modes, auto_source needs to first check if rlogs exist for any source if mode in [ReadMode.AUTO, ReadMode.AUTO_INTERACTIVE]: @@ -190,9 +191,10 @@ def auto_source(sr: SegmentRange, mode=ReadMode.RLOG) -> LogPaths: try: return check_source(source, sr, mode) except Exception as e: - exceptions.append(e) + exceptions[source.__name__] = e - raise Exception(f"auto_source could not find any valid source, exceptions for sources: {exceptions}") + raise Exception("auto_source could not find any valid source, exceptions for sources:\n - " + + "\n - ".join([f"{k}: {repr(v)}" for k, v in exceptions.items()])) def parse_useradmin(identifier: str):