diff --git a/earthaccess/search.py b/earthaccess/search.py index 0ed3b61d..8392ca51 100644 --- a/earthaccess/search.py +++ b/earthaccess/search.py @@ -238,7 +238,10 @@ def get(self, limit: int = 2000) -> list: try: response.raise_for_status() except exceptions.HTTPError as ex: - raise RuntimeError(ex.response.text) + if ex.response is not None: + raise RuntimeError(ex.response.text) from ex + else: + raise RuntimeError(str(ex)) from ex if self._format == "json": latest = response.json()["feed"]["entry"] @@ -333,7 +336,10 @@ def hits(self) -> int: try: response.raise_for_status() except exceptions.HTTPError as ex: - raise RuntimeError(ex.response.text) + if ex.response is not None: + raise RuntimeError(ex.response.text) from ex + else: + raise RuntimeError(str(ex)) from ex return int(response.headers["CMR-Hits"]) @@ -561,7 +567,10 @@ def get(self, limit: int = 2000) -> list: try: response.raise_for_status() except exceptions.HTTPError as ex: - raise RuntimeError(ex.response.text) + if ex.response is not None: + raise RuntimeError(ex.response.text) from ex + else: + raise RuntimeError(str(ex)) from ex if self._format == "json": latest = response.json()["feed"]["entry"] diff --git a/poetry.lock b/poetry.lock index f33eef26..570b5560 100644 --- a/poetry.lock +++ b/poetry.lock @@ -4968,4 +4968,4 @@ kerchunk = ["dask", "kerchunk"] [metadata] lock-version = "2.0" python-versions = ">=3.8,<4.0" -content-hash = "8c6dfb95442e8a609cae73163a9ff06ba02cb2971da057703c348c5844b5b9f9" +content-hash = "0d6e2ea41a87545f783db799a6aeccca342298b1e4e5a704e3e0aaeb6ab14ea3"