Skip to content

Commit

Permalink
LogReader: improve error messages (commaai#32747)
Browse files Browse the repository at this point in the history
* better error messages

* clean up
  • Loading branch information
sshane authored Jun 14, 2024
1 parent 6552d4e commit 3ede1e2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tools/lib/logreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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]:
Expand All @@ -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):
Expand Down

0 comments on commit 3ede1e2

Please sign in to comment.