fix(simpy): report a non-UTF-8 resource CSV as unreadable, not as a bad integer (#259)

UnicodeError is a ValueError subclass, so the 'invalid integer' handler was catching decode failures first. Swap the two except clauses so a non-UTF-8 CSV is reported as unreadable.
This commit is contained in:
Tai An authored and GitHub committed 2026-09-10 15:48:40 -07:00
1 parent 34ad8b73bf
commit cfefe8b84f
1 file changed
+2 -2
+2 -2
View File
@@ -199,10 +199,10 @@ def summarize_resource_csv(path: Path, *, max_records: int) -> dict[str, Any]:
}
)
event_counts[event] += 1
except ValueError as exc:
raise CliError(f"resource CSV contains an invalid integer: {exc}") from exc
except (OSError, UnicodeError, csv.Error) as exc:
raise CliError(f"cannot read resource CSV {path.name}: {exc}") from exc
except ValueError as exc:
raise CliError(f"resource CSV contains an invalid integer: {exc}") from exc
if len(samples) < 2:
raise CliError("resource CSV needs at least an initial and final sample")
start = samples[0]["time"]