Skip to content

Commit 12a9c52

Browse files
committed
Fix exception from get and post requests
We should let the exception raise up as that is what downstream expects
1 parent 74b496a commit 12a9c52

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

onvif/zeep_aiohttp.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from zeep.utils import get_version
1212
from zeep.wsdl.utils import etree_to_string
1313

14-
import aiohttp
1514
import httpx
1615
from aiohttp import ClientResponse, ClientSession
1716
from requests import Response
@@ -176,8 +175,6 @@ async def _post(
176175

177176
except TimeoutError as exc:
178177
raise TimeoutError(f"Request to {address} timed out") from exc
179-
except aiohttp.ClientError as exc:
180-
raise ConnectionError(f"Error connecting to {address}: {exc}") from exc
181178

182179
async def post_xml(
183180
self, address: str, envelope: _Element, headers: dict[str, str]
@@ -255,8 +252,6 @@ async def _get(
255252

256253
except TimeoutError as exc:
257254
raise TimeoutError(f"Request to {address} timed out") from exc
258-
except aiohttp.ClientError as exc:
259-
raise ConnectionError(f"Error connecting to {address}: {exc}") from exc
260255

261256
def _httpx_to_requests_response(self, response: httpx.Response) -> Response:
262257
"""Convert an httpx.Response object to a requests.Response object"""

tests/test_zeep_transport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ async def test_connection_error_handling():
201201

202202
transport.session = mock_session
203203

204-
with pytest.raises(ConnectionError, match="Error connecting to"):
204+
with pytest.raises(aiohttp.ClientError, match="Connection failed"):
205205
await transport.get("http://example.com/wsdl")
206206

207207

0 commit comments

Comments
 (0)