From fb13b6e918eb751255663785a0be1dca4f2d867f Mon Sep 17 00:00:00 2001 From: Charles Ojukwu Date: Mon, 13 Jan 2025 16:45:40 +0000 Subject: [PATCH 1/4] fix: raise exception when response has an error --- vortexasdk/client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vortexasdk/client.py b/vortexasdk/client.py index 1706402b..847579dc 100644 --- a/vortexasdk/client.py +++ b/vortexasdk/client.py @@ -82,8 +82,14 @@ def search_base( probe_response = _send_post_request( url, payload, size=1, headers=headers ) + + if "error" in probe_response: + raise Exception(probe_response) + total = self._calculate_total(probe_response) + print(probe_response) + if total > self._MAX_ALLOWED_TOTAL: raise Exception( f"Attempting to query too many records at once. Attempted records: {total}, Max allowed records: {self._MAX_ALLOWED_TOTAL} . " From 44008e5f34ecc0ef8e997bea08d89781e4701a37 Mon Sep 17 00:00:00 2001 From: Charles Ojukwu Date: Mon, 13 Jan 2025 16:49:12 +0000 Subject: [PATCH 2/4] chore: version bump --- vortexasdk/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vortexasdk/version.py b/vortexasdk/version.py index 92192eed..68cdeee4 100644 --- a/vortexasdk/version.py +++ b/vortexasdk/version.py @@ -1 +1 @@ -__version__ = "1.0.4" +__version__ = "1.0.5" From 0f130755b7cf9a302cdb8d06fe188a96ad051322 Mon Sep 17 00:00:00 2001 From: Charles Ojukwu Date: Tue, 14 Jan 2025 09:41:20 +0000 Subject: [PATCH 3/4] chore: remove print --- vortexasdk/client.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/vortexasdk/client.py b/vortexasdk/client.py index 847579dc..cf4215de 100644 --- a/vortexasdk/client.py +++ b/vortexasdk/client.py @@ -88,8 +88,6 @@ def search_base( total = self._calculate_total(probe_response) - print(probe_response) - if total > self._MAX_ALLOWED_TOTAL: raise Exception( f"Attempting to query too many records at once. Attempted records: {total}, Max allowed records: {self._MAX_ALLOWED_TOTAL} . " From bc34d2e8456c811dd85d04071cda55a421197ac3 Mon Sep 17 00:00:00 2001 From: Charles Ojukwu Date: Tue, 14 Jan 2025 10:43:24 +0000 Subject: [PATCH 4/4] chore: specific exception type --- vortexasdk/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vortexasdk/client.py b/vortexasdk/client.py index cf4215de..9398f32f 100644 --- a/vortexasdk/client.py +++ b/vortexasdk/client.py @@ -8,7 +8,7 @@ from typing import Any, Dict, List, Optional from urllib.parse import urlencode -from requests import Response +from requests import Response, RequestException from tqdm import tqdm from vortexasdk import __name__ as sdk_pkg_name @@ -84,7 +84,7 @@ def search_base( ) if "error" in probe_response: - raise Exception(probe_response) + raise RequestException(probe_response) total = self._calculate_total(probe_response)