Skip to content

Commit 9077342

Browse files
committed
More meaningful errors
1 parent d42c74a commit 9077342

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

deepstack/core.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,14 @@ def detect(self, image_bytes: bytes):
124124
response = post_image(url, image_bytes, self._api_key, self._timeout)
125125

126126
if not response.status_code == HTTP_OK:
127-
raise DeepstackException(f"Error from request: {response.status_code}")
127+
raise DeepstackException(
128+
f"Error from request, status code: {response.status_code}"
129+
)
128130
return
129131

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

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

224227
if not response.status_code == HTTP_OK:
225-
raise DeepstackException(f"Error from request: {response.status_code}")
228+
raise DeepstackException(
229+
f"Error from request, status code: {response.status_code}"
230+
)
226231
return
227232

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

0 commit comments

Comments
 (0)