Skip to content

Commit 0aec147

Browse files
Merge pull request #2109 from VWS-Python/move-back-toomanyrequests
Move back TooManyRequests
2 parents 26efcea + 28611d4 commit 0aec147

File tree

3 files changed

+18
-33
lines changed

3 files changed

+18
-33
lines changed

src/vws/exceptions/custom_exceptions.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,3 @@ def response(self) -> Response:
6363
The response returned by Vuforia which included this error.
6464
"""
6565
return self._response
66-
67-
68-
class TooManyRequests(Exception): # pragma: no cover
69-
"""
70-
Exception raised when Vuforia returns a response with a result code
71-
'TooManyRequests'.
72-
"""
73-
74-
def __init__(self, response: Response) -> None:
75-
"""
76-
Args:
77-
response: The response returned by Vuforia.
78-
"""
79-
super().__init__(response.text)
80-
self._response = response
81-
82-
@property
83-
def response(self) -> Response:
84-
"""
85-
The response returned by Vuforia which included this error.
86-
"""
87-
return self._response

src/vws/exceptions/vws_exceptions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,10 @@ def target_id(self) -> str:
164164
# Every HTTP path which can raise this error is in the format
165165
# `/something/{target_id}`.
166166
return path.split(sep="/", maxsplit=2)[-1]
167+
168+
169+
class TooManyRequests(VWSException): # pragma: no cover
170+
"""
171+
Exception raised when Vuforia returns a response with a result code
172+
'TooManyRequests'.
173+
"""

src/vws/vws.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
OopsAnErrorOccurredPossiblyBadName,
2121
ServerError,
2222
TargetProcessingTimeout,
23-
TooManyRequests,
2423
)
2524
from vws.exceptions.vws_exceptions import (
2625
AuthenticationFailure,
@@ -38,6 +37,7 @@
3837
TargetQuotaReached,
3938
TargetStatusNotSuccess,
4039
TargetStatusProcessing,
40+
TooManyRequests,
4141
UnknownTarget,
4242
)
4343
from vws.reports import (
@@ -169,7 +169,7 @@ def _make_request(
169169
character.
170170
~vws.exceptions.custom_exceptions.ServerError: There is an error
171171
with Vuforia's servers.
172-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
172+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
173173
limiting access.
174174
json.decoder.JSONDecodeError: The server did not respond with valid
175175
JSON. This may happen if the server address is not a valid
@@ -280,7 +280,7 @@ def add_target(
280280
includes a bad character.
281281
~vws.exceptions.custom_exceptions.ServerError: There is an error
282282
with Vuforia's servers.
283-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
283+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
284284
limiting access.
285285
"""
286286
image_data = _get_image_data(image=image)
@@ -330,7 +330,7 @@ def get_target_record(self, target_id: str) -> TargetStatusAndRecord:
330330
error with the time sent to Vuforia.
331331
~vws.exceptions.custom_exceptions.ServerError: There is an error
332332
with Vuforia's servers.
333-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
333+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
334334
limiting access.
335335
"""
336336
response = self._make_request(
@@ -391,7 +391,7 @@ def wait_for_target_processed(
391391
error with the time sent to Vuforia.
392392
~vws.exceptions.custom_exceptions.ServerError: There is an error
393393
with Vuforia's servers.
394-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
394+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
395395
limiting access.
396396
"""
397397
start_time = time.monotonic()
@@ -426,7 +426,7 @@ def list_targets(self) -> list[str]:
426426
error with the time sent to Vuforia.
427427
~vws.exceptions.custom_exceptions.ServerError: There is an error
428428
with Vuforia's servers.
429-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
429+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
430430
limiting access.
431431
"""
432432
response = self._make_request(
@@ -463,7 +463,7 @@ def get_target_summary_report(self, target_id: str) -> TargetSummaryReport:
463463
error with the time sent to Vuforia.
464464
~vws.exceptions.custom_exceptions.ServerError: There is an error
465465
with Vuforia's servers.
466-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
466+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
467467
limiting access.
468468
"""
469469
response = self._make_request(
@@ -506,7 +506,7 @@ def get_database_summary_report(self) -> DatabaseSummaryReport:
506506
error with the time sent to Vuforia.
507507
~vws.exceptions.custom_exceptions.ServerError: There is an error
508508
with Vuforia's servers.
509-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
509+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
510510
limiting access.
511511
"""
512512
response = self._make_request(
@@ -556,7 +556,7 @@ def delete_target(self, target_id: str) -> None:
556556
error with the time sent to Vuforia.
557557
~vws.exceptions.custom_exceptions.ServerError: There is an error
558558
with Vuforia's servers.
559-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
559+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
560560
limiting access.
561561
"""
562562
self._make_request(
@@ -593,7 +593,7 @@ def get_duplicate_targets(self, target_id: str) -> list[str]:
593593
error with the time sent to Vuforia.
594594
~vws.exceptions.custom_exceptions.ServerError: There is an error
595595
with Vuforia's servers.
596-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
596+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
597597
limiting access.
598598
"""
599599
response = self._make_request(
@@ -656,7 +656,7 @@ def update_target(
656656
error with the time sent to Vuforia.
657657
~vws.exceptions.custom_exceptions.ServerError: There is an error
658658
with Vuforia's servers.
659-
~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
659+
~vws.exceptions.vws_exceptions.TooManyRequests: Vuforia is rate
660660
limiting access.
661661
"""
662662
data: dict[str, str | bool | float | int] = {}

0 commit comments

Comments
 (0)