Skip to content

Commit 966006c

Browse files
committed
better error message for JSON failure
1 parent 80cc484 commit 966006c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tools/src/scie_pants/pants_version.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,19 @@ def get_bootstrap_urls(bootstrap_urls_paths: Iterable[str]) -> dict[str, str] |
222222

223223
ptex_urls: dict[str, str] = {}
224224
for bootstrap_urls_path in bootstrap_urls_paths:
225-
bootstrap_urls = json.loads(Path(bootstrap_urls_path).read_text())
225+
try:
226+
bootstrap_urls = json.loads(Path(bootstrap_urls_path).read_text())
227+
except json.decoder.JSONDecodeError as e:
228+
raise ValueError(
229+
f"Failed to parse JSON from PANTS_BOOTSTRAP_URLS file `{bootstrap_urls_path}`: {e}"
230+
)
231+
226232
candidate_ptex_urls = bootstrap_urls.get("ptex")
227233
if candidate_ptex_urls is None:
228234
raise ValueError(
229235
f"Missing 'ptex' key in PANTS_BOOTSTRAP_URLS file: {bootstrap_urls_path}"
230236
)
237+
231238
for key, url in candidate_ptex_urls.items():
232239
if not isinstance(url, str):
233240
raise TypeError(

0 commit comments

Comments
 (0)