From 9077342c48b0a3f5951d0c0cf77363f5462dda1c Mon Sep 17 00:00:00 2001 From: Robin Cole Date: Sun, 24 May 2020 05:26:30 +0100 Subject: [PATCH 1/3] More meaningful errors --- deepstack/core.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/deepstack/core.py b/deepstack/core.py index ca214c3..17e1742 100644 --- a/deepstack/core.py +++ b/deepstack/core.py @@ -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 = response.json()["error"] raise DeepstackException(f"Error from Deepstack: {error}") @property @@ -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 = response.json()["error"] raise DeepstackException(f"Error from Deepstack: {error}") From 3180612df29f1869c647d1137573f3cc90b27caa Mon Sep 17 00:00:00 2001 From: Robin Cole Date: Sun, 24 May 2020 05:31:00 +0100 Subject: [PATCH 2/3] Update core.py --- deepstack/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepstack/core.py b/deepstack/core.py index 17e1742..c29fe24 100644 --- a/deepstack/core.py +++ b/deepstack/core.py @@ -232,5 +232,5 @@ def recognise(self, image_bytes: bytes): self._response = response.json() if not self._response["success"]: - error = response.json()["error"] + error = self._response["error"] raise DeepstackException(f"Error from Deepstack: {error}") From 8fcd2fb1966a5593f6757fe217a716be6fd8dd1a Mon Sep 17 00:00:00 2001 From: Robin Cole Date: Sun, 24 May 2020 05:33:10 +0100 Subject: [PATCH 3/3] Update core.py --- deepstack/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepstack/core.py b/deepstack/core.py index c29fe24..d29903f 100644 --- a/deepstack/core.py +++ b/deepstack/core.py @@ -131,7 +131,7 @@ def detect(self, image_bytes: bytes): self._response = response.json() if not self._response["success"]: - error = response.json()["error"] + error = self._response["error"] raise DeepstackException(f"Error from Deepstack: {error}") @property