Skip to content

Commit 200f9e6

Browse files
committed
Raise error on too many requests even when there is no JSON text
1 parent 1cf4459 commit 200f9e6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/vws/vws.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import json
99
import time
1010
from datetime import date
11+
from http import HTTPStatus
1112
from typing import TYPE_CHECKING, BinaryIO
1213
from urllib.parse import urljoin
1314

@@ -181,6 +182,12 @@ def _make_request(
181182
if "Oops, an error occurred" in response.text:
182183
raise UnknownVWSErrorPossiblyBadName
183184

185+
if (
186+
response.status_code == HTTPStatus.TOO_MANY_REQUESTS
187+
): # pragma: no cover
188+
# The Vuforia API returns a 429 response with no JSON body.
189+
raise TooManyRequests(response=response)
190+
184191
result_code = response.json()["result_code"]
185192

186193
if result_code == expected_result_code:
@@ -202,7 +209,6 @@ def _make_request(
202209
"TargetQuotaReached": TargetQuotaReached,
203210
"TargetStatusNotSuccess": TargetStatusNotSuccess,
204211
"TargetStatusProcessing": TargetStatusProcessing,
205-
"TooManyRequests": TooManyRequests,
206212
"UnknownTarget": UnknownTarget,
207213
}[result_code]
208214

0 commit comments

Comments
 (0)