Skip to content

Commit 15d8093

Browse files
authored
httpcore/backends/trio: map OSError exceptions (#543)
The underlying socket implementations can raise OSError for situations such as `getaddrinfo` failing to resolve an address. Previously, these errors would not be mapped to httpcore exception types for the trio backend. Now, map OSError exceptions in the trio backend to ConnectError. This will make trio consistent with the asyncio backend. Signed-off-by: Vincent Fazio <vfazio@xes-inc.com>
1 parent 1bf9cf2 commit 15d8093

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

httpcore/backends/trio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ async def connect_tcp(
111111
exc_map = {
112112
trio.TooSlowError: ConnectTimeout,
113113
trio.BrokenResourceError: ConnectError,
114+
OSError: ConnectError,
114115
}
115116
# Trio supports 'local_address' from 0.16.1 onwards.
116117
# We only include the keyword argument if a local_address
@@ -130,6 +131,7 @@ async def connect_unix_socket(
130131
exc_map = {
131132
trio.TooSlowError: ConnectTimeout,
132133
trio.BrokenResourceError: ConnectError,
134+
OSError: ConnectError,
133135
}
134136
with map_exceptions(exc_map):
135137
with trio.fail_after(timeout_or_inf):

0 commit comments

Comments
 (0)