|
5 | 5 | from __future__ import annotations |
6 | 6 |
|
7 | 7 | import datetime |
| 8 | +from http import HTTPStatus |
8 | 9 | import io |
9 | 10 | from urllib.parse import urljoin |
10 | 11 |
|
|
21 | 22 | RequestTimeTooSkewed, |
22 | 23 | ) |
23 | 24 | from vws.exceptions.custom_exceptions import ( |
24 | | - ConnectionErrorPossiblyImageTooLarge, |
| 25 | + RequestEntityTooLarge, |
25 | 26 | ) |
26 | 27 | from vws.include_target_data import CloudRecoIncludeTargetData |
27 | 28 | from vws.reports import QueryResult, TargetData |
@@ -82,13 +83,13 @@ def query( |
82 | 83 | deleted and Vuforia returns an error in this case. |
83 | 84 | ~vws.exceptions.cloud_reco_exceptions.InactiveProject: The project |
84 | 85 | is inactive. |
85 | | - ~vws.exceptions.custom_exceptions.ConnectionErrorPossiblyImageTooLarge: |
86 | | - The given image is too large. |
87 | 86 | ~vws.exceptions.cloud_reco_exceptions.RequestTimeTooSkewed: There |
88 | 87 | is an error with the time sent to Vuforia. |
89 | 88 | ~vws.exceptions.cloud_reco_exceptions.BadImage: There is a problem |
90 | 89 | with the given image. For example, it must be a JPEG or PNG |
91 | 90 | file in the grayscale or RGB color space. |
| 91 | + ~vws.exceptions.custom_exceptions.RequestEntityTooLarge: |
| 92 | + The given image is too large. |
92 | 93 |
|
93 | 94 | Returns: |
94 | 95 | An ordered list of target details of matching targets. |
@@ -125,18 +126,15 @@ def query( |
125 | 126 | 'Content-Type': content_type_header, |
126 | 127 | } |
127 | 128 |
|
128 | | - try: |
129 | | - response = requests.request( |
130 | | - method=method, |
131 | | - url=urljoin(base=self._base_vwq_url, url=request_path), |
132 | | - headers=headers, |
133 | | - data=content, |
134 | | - ) |
135 | | - except requests.exceptions.ConnectionError as exc: |
136 | | - raise ConnectionErrorPossiblyImageTooLarge( |
137 | | - request=exc.request, |
138 | | - response=exc.response, |
139 | | - ) from exc |
| 129 | + response = requests.request( |
| 130 | + method=method, |
| 131 | + url=urljoin(base=self._base_vwq_url, url=request_path), |
| 132 | + headers=headers, |
| 133 | + data=content, |
| 134 | + ) |
| 135 | + |
| 136 | + if response.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE: |
| 137 | + raise RequestEntityTooLarge |
140 | 138 |
|
141 | 139 | if 'Integer out of range' in response.text: |
142 | 140 | raise MaxNumResultsOutOfRange(response=response) |
|
0 commit comments