File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ Changelog
44Next
55----
66
7+ * Return a new error (``vws.custom_exceptions.ServerError ``) when the server returns a 5xx status code.
8+
792023.12.27
810------------
911
Original file line number Diff line number Diff line change @@ -42,3 +42,24 @@ class TargetProcessingTimeout(Exception):
4242 """
4343 Exception raised when waiting for a target to be processed times out.
4444 """
45+
46+
47+ class ServerError (Exception ): # pragma: no cover
48+ """
49+ Exception raised when VWS returns a server error.
50+ """
51+
52+ def __init__ (self , response : Response ) -> None :
53+ """
54+ Args:
55+ response: The response returned by Vuforia.
56+ """
57+ super ().__init__ (response .text )
58+ self ._response = response
59+
60+ @property
61+ def response (self ) -> Response :
62+ """
63+ The response returned by Vuforia which included this error.
64+ """
65+ return self ._response
Original file line number Diff line number Diff line change 2222)
2323from vws .exceptions .custom_exceptions import (
2424 RequestEntityTooLarge ,
25+ ServerError ,
2526)
2627from vws .include_target_data import CloudRecoIncludeTargetData
2728from vws .reports import QueryResult , TargetData
@@ -145,6 +146,11 @@ def query(
145146 if "Integer out of range" in response .text :
146147 raise MaxNumResultsOutOfRange (response = response )
147148
149+ if (
150+ response .status_code >= HTTPStatus .INTERNAL_SERVER_ERROR
151+ ): # pragma: no cover
152+ raise ServerError (response = response )
153+
148154 result_code = response .json ()["result_code" ]
149155 if result_code != "Success" :
150156 exception = {
Original file line number Diff line number Diff line change 1818
1919from vws .exceptions .custom_exceptions import (
2020 OopsAnErrorOccurredPossiblyBadName ,
21+ ServerError ,
2122 TargetProcessingTimeout ,
2223)
2324from vws .exceptions .vws_exceptions import (
@@ -188,6 +189,11 @@ def _make_request(
188189 # The Vuforia API returns a 429 response with no JSON body.
189190 raise TooManyRequests (response = response )
190191
192+ if (
193+ response .status_code >= HTTPStatus .INTERNAL_SERVER_ERROR
194+ ): # pragma: no cover
195+ raise ServerError (response = response )
196+
191197 result_code = response .json ()["result_code" ]
192198
193199 if result_code == expected_result_code :
You can’t perform that action at this time.
0 commit comments