Skip to content

Commit

Permalink
Improve traceability in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhoey committed Aug 21, 2023
1 parent f56cbdd commit fd5cd23
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/vptstools/odimh5.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,10 @@ def check_vp_odim(source_odim: ODIMReader) -> None:
"""Verify ODIM file is an hdf5 ODIM format containing 'VP' data."""
if not {"what", "how", "where"}.issubset(source_odim.hdf5.keys()):
raise InvalidSourceODIM(
"No hdf5 ODIM format: File does not contain what/how/where "
"group information."
f"No hdf5 ODIM format: File {source_odim.hdf5} does not contain what/how/where group information."
)
if source_odim.root_object_str != "VP":
raise InvalidSourceODIM(
f"Incorrect what.object value: expected VP, "
f"found {source_odim.root_object_str}"
f"Incorrect what.object value in file {source_odim.hdf5}: expected VP, "
f"found {source_odim.root_object_str}. "
)
2 changes: 1 addition & 1 deletion src/vptstools/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def parse_file_name(file_name):
radar_code = country + radar
return radar_code, data_type, year, month, day, hour, minute, file_name
else:
raise ValueError("File name is not a valid ODIM h5 file.")
raise ValueError(f"File name {file_name} is not a valid ODIM h5 file.")

@property
def country(self):
Expand Down
2 changes: 1 addition & 1 deletion src/vptstools/vpts.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class BirdProfile:
def __post_init__(self):
if not isinstance(self.source_file, str):
raise TypeError(
"Source_file need to be a str representation of a file path."
f"Source_file {self.source_file} need to be a str representation of a file path."
)

def __lt__(self, other): # Allows sorting by datetime
Expand Down

0 comments on commit fd5cd23

Please sign in to comment.