1818
1919from vws .exceptions .custom_exceptions import (
2020 OopsAnErrorOccurredPossiblyBadName ,
21+ ServerError ,
2122 TargetProcessingTimeout ,
23+ TooManyRequests ,
2224)
2325from vws .exceptions .vws_exceptions import (
2426 AuthenticationFailure ,
3638 TargetQuotaReached ,
3739 TargetStatusNotSuccess ,
3840 TargetStatusProcessing ,
39- TooManyRequests ,
4041 UnknownTarget ,
4142)
4243from vws .reports import (
@@ -166,6 +167,10 @@ def _make_request(
166167 an HTML page with the text "Oops, an error occurred". This has
167168 been seen to happen when the given name includes a bad
168169 character.
170+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
171+ with Vuforia's servers.
172+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
173+ limiting access.
169174 json.decoder.JSONDecodeError: The server did not respond with valid
170175 JSON. This may happen if the server address is not a valid
171176 Vuforia server.
@@ -188,6 +193,11 @@ def _make_request(
188193 # The Vuforia API returns a 429 response with no JSON body.
189194 raise TooManyRequests (response = response )
190195
196+ if (
197+ response .status_code >= HTTPStatus .INTERNAL_SERVER_ERROR
198+ ): # pragma: no cover
199+ raise ServerError (response = response )
200+
191201 result_code = response .json ()["result_code" ]
192202
193203 if result_code == expected_result_code :
@@ -268,6 +278,10 @@ def add_target(
268278 Vuforia returns an HTML page with the text "Oops, an error
269279 occurred". This has been seen to happen when the given name
270280 includes a bad character.
281+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
282+ with Vuforia's servers.
283+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
284+ limiting access.
271285 """
272286 image_data = _get_image_data (image = image )
273287 image_data_encoded = base64 .b64encode (image_data ).decode ("ascii" )
@@ -314,6 +328,10 @@ def get_target_record(self, target_id: str) -> TargetStatusAndRecord:
314328 does not match a target in the database.
315329 ~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
316330 error with the time sent to Vuforia.
331+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
332+ with Vuforia's servers.
333+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
334+ limiting access.
317335 """
318336 response = self ._make_request (
319337 method = "GET" ,
@@ -371,6 +389,10 @@ def wait_for_target_processed(
371389 does not match a target in the database.
372390 ~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
373391 error with the time sent to Vuforia.
392+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
393+ with Vuforia's servers.
394+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
395+ limiting access.
374396 """
375397 start_time = time .monotonic ()
376398 while True :
@@ -402,6 +424,10 @@ def list_targets(self) -> list[str]:
402424 known database.
403425 ~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
404426 error with the time sent to Vuforia.
427+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
428+ with Vuforia's servers.
429+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
430+ limiting access.
405431 """
406432 response = self ._make_request (
407433 method = "GET" ,
@@ -435,6 +461,10 @@ def get_target_summary_report(self, target_id: str) -> TargetSummaryReport:
435461 does not match a target in the database.
436462 ~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
437463 error with the time sent to Vuforia.
464+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
465+ with Vuforia's servers.
466+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
467+ limiting access.
438468 """
439469 response = self ._make_request (
440470 method = "GET" ,
@@ -474,6 +504,10 @@ def get_database_summary_report(self) -> DatabaseSummaryReport:
474504 known database.
475505 ~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
476506 error with the time sent to Vuforia.
507+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
508+ with Vuforia's servers.
509+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
510+ limiting access.
477511 """
478512 response = self ._make_request (
479513 method = "GET" ,
@@ -520,6 +554,10 @@ def delete_target(self, target_id: str) -> None:
520554 target is in the processing state.
521555 ~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
522556 error with the time sent to Vuforia.
557+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
558+ with Vuforia's servers.
559+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
560+ limiting access.
523561 """
524562 self ._make_request (
525563 method = "DELETE" ,
@@ -553,6 +591,10 @@ def get_duplicate_targets(self, target_id: str) -> list[str]:
553591 inactive.
554592 ~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
555593 error with the time sent to Vuforia.
594+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
595+ with Vuforia's servers.
596+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
597+ limiting access.
556598 """
557599 response = self ._make_request (
558600 method = "GET" ,
@@ -612,6 +654,10 @@ def update_target(
612654 inactive.
613655 ~vws.exceptions.vws_exceptions.RequestTimeTooSkewed: There is an
614656 error with the time sent to Vuforia.
657+ ~vws.exceptions.custom_exceptions.ServerError: There is an error
658+ with Vuforia's servers.
659+ ~vws.exceptions.custom_exceptions.TooManyRequests: Vuforia is rate
660+ limiting access.
615661 """
616662 data : dict [str , str | bool | float | int ] = {}
617663
0 commit comments