1
0
mirror of synced 2024-11-27 22:40:49 +01:00

writers.py: Add clear error for struct.pack

This commit is contained in:
Viv 2024-02-10 18:07:59 -05:00
parent 7f3b38b92c
commit d4c3abb672

View File

@ -57,5 +57,8 @@ def write_struct(file: BinaryIO,
format_string: str,
value_list: List[Any]) -> None:
"""Pack (int, float, etc.) values into a string of bytes, then write."""
try:
packed_bytes = struct.pack(order + format_string, *value_list)
except struct.error as err:
raise ValueError(f"Can't fmt {value_list} as {format_string}") from err
file.write(packed_bytes)