Skip to content

Commit

Permalink
Merge pull request #22 from robmarkcole/fix-error
Browse files Browse the repository at this point in the history
More meaningful errors
  • Loading branch information
robmarkcole authored May 24, 2020
2 parents d42c74a + 8fcd2fb commit cd0e6fb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions deepstack/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,14 @@ def detect(self, image_bytes: bytes):
response = post_image(url, image_bytes, self._api_key, self._timeout)

if not response.status_code == HTTP_OK:
raise DeepstackException(f"Error from request: {response.status_code}")
raise DeepstackException(
f"Error from request, status code: {response.status_code}"
)
return

self._response = response.json()
if not self._response["success"]:
error = self._response["error"]
raise DeepstackException(f"Error from Deepstack: {error}")

@property
Expand Down Expand Up @@ -222,9 +225,12 @@ def recognise(self, image_bytes: bytes):
response = post_image(url, image_bytes, self._api_key, self._timeout)

if not response.status_code == HTTP_OK:
raise DeepstackException(f"Error from request: {response.status_code}")
raise DeepstackException(
f"Error from request, status code: {response.status_code}"
)
return

self._response = response.json()
if not self._response["success"]:
error = self._response["error"]
raise DeepstackException(f"Error from Deepstack: {error}")

0 comments on commit cd0e6fb

Please sign in to comment.