Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/vws/exceptions/custom_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ class RequestEntityTooLarge(Exception):
Exception raised when the given image is too large.
"""

def __init__(self, response: Response) -> None:
"""
Args:
response: The response returned by Vuforia.
"""
super().__init__(response.text)
self._response = response

@property
def response(self) -> Response:
"""
The response returned by Vuforia which included this error.
"""
return self._response


class TargetProcessingTimeout(Exception):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/vws/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def query(
)

if response.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE:
raise RequestEntityTooLarge
raise RequestEntityTooLarge(response=response)

if "Integer out of range" in response.text:
raise MaxNumResultsOutOfRange(response=response)
Expand Down
6 changes: 5 additions & 1 deletion tests/test_cloud_reco_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ def test_image_too_large(
A ``RequestEntityTooLarge`` exception is raised if an image which is too
large is given.
"""
with pytest.raises(RequestEntityTooLarge):
with pytest.raises(RequestEntityTooLarge) as exc:
cloud_reco_client.query(image=png_too_large)

assert (
exc.value.response.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE
)


def test_cloudrecoexception_inheritance() -> None:
"""
Expand Down