diff --git a/deepgram/clients/common/v1/abstract_async_rest.py b/deepgram/clients/common/v1/abstract_async_rest.py index 1a3be9cd..3c0d8056 100644 --- a/deepgram/clients/common/v1/abstract_async_rest.py +++ b/deepgram/clients/common/v1/abstract_async_rest.py @@ -229,6 +229,13 @@ async def _handle_request( method, _url, headers=_headers, **kwargs ) response.raise_for_status() + + # throw exception if response is None or response.text is None + if response is None or response.text is None: + raise DeepgramError( + "Response is not available yet. Please try again later." + ) + return response.text except httpx.HTTPError as e1: diff --git a/deepgram/clients/common/v1/abstract_sync_rest.py b/deepgram/clients/common/v1/abstract_sync_rest.py index 5aba233f..cbfd40ef 100644 --- a/deepgram/clients/common/v1/abstract_sync_rest.py +++ b/deepgram/clients/common/v1/abstract_sync_rest.py @@ -225,6 +225,13 @@ def _handle_request( kwargs.pop("transport") response = client.request(method, _url, headers=_headers, **kwargs) response.raise_for_status() + + # throw exception if response is None or response.text is None + if response is None or response.text is None: + raise DeepgramError( + "Response is not available yet. Please try again later." + ) + return response.text except httpx.HTTPError as e1: