diff --git a/trino/client.py b/trino/client.py index 2037deb2..b0b6bb30 100644 --- a/trino/client.py +++ b/trino/client.py @@ -787,7 +787,11 @@ def execute(self, additional_http_headers=None) -> TrinoResult: if self.cancelled: raise exceptions.TrinoUserError("Query has been cancelled", self.query_id) - response = self._request.post(self._query, additional_http_headers) + try: + response = self._request.post(self._query, additional_http_headers) + except requests.exceptions.RequestException as e: + raise trino.exceptions.TrinoConnectionError("failed to execute: {}".format(e)) + status = self._request.process(response) self._info_uri = status.info_uri self._query_id = status.id