Skip to content

Commit bc1b34a

Browse files
authored
Merge pull request #580 from okurz/fix/style_list_incidents
fix(openqa-list-incidents): replace asserts with error handling
2 parents f78b32f + 1d0d776 commit bc1b34a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

openqa-list-incidents

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,15 @@ def get_api_url(job: str) -> str:
213213
data = got.json()
214214
except RequestException as error:
215215
sys.exit(f"ERROR: {job}: {error}")
216-
assert len(data) == 1
216+
if len(data) != 1:
217+
sys.exit(f"ERROR: {job}: expected 1 job, got {len(data)}")
217218
job = str(data[0]["id"])
218219
else:
219220
# Support both "/t1234" & "/tests/1234"
220221
job = pathlib.Path(url.path).name.removeprefix("t")
221222

222-
assert job.isdigit()
223+
if not job.isdigit():
224+
sys.exit(f"ERROR: {job}: invalid job ID")
223225
return f"https://{url.netloc}/api/v1/jobs/{job}"
224226

225227

0 commit comments

Comments
 (0)