Skip to content

Commit

Permalink
Added httpcore.SSLError and redirect TLS handshake errors to it.
Browse files Browse the repository at this point in the history
  • Loading branch information
T-256 committed Oct 4, 2024
1 parent 4ee1ca2 commit f8babb3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

- Added httpcore.SSLError and redirect TLS handshake errors to it. (#960)

## Version 1.0.6 (October 1st, 2024)

- Relax `trio` dependency pinning. (#956)
Expand Down
1 change: 1 addition & 0 deletions docs/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The following exceptions may be raised when sending a request:
* `httpcore.WriteTimeout`
* `httpcore.NetworkError`
* `httpcore.ConnectError`
* `httpcore.SSLError`
* `httpcore.ReadError`
* `httpcore.WriteError`
* `httpcore.ProtocolError`
Expand Down
2 changes: 2 additions & 0 deletions httpcore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ReadError,
ReadTimeout,
RemoteProtocolError,
SSLError,
TimeoutException,
UnsupportedProtocol,
WriteError,
Expand Down Expand Up @@ -128,6 +129,7 @@ def __init__(self, *args, **kwargs): # type: ignore
"ConnectError",
"ReadError",
"WriteError",
"SSLError",
]

__version__ = "1.0.6"
Expand Down
3 changes: 2 additions & 1 deletion httpcore/_backends/anyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ConnectTimeout,
ReadError,
ReadTimeout,
SSLError,
WriteError,
WriteTimeout,
map_exceptions,
Expand Down Expand Up @@ -64,7 +65,7 @@ async def start_tls(
TimeoutError: ConnectTimeout,
anyio.BrokenResourceError: ConnectError,
anyio.EndOfStream: ConnectError,
ssl.SSLError: ConnectError,
ssl.SSLError: SSLError,
}
with map_exceptions(exc_map):
try:
Expand Down
5 changes: 5 additions & 0 deletions httpcore/_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
import ssl
from typing import Iterator, Mapping, Type

ExceptionMapping = Mapping[Type[Exception], Type[Exception]]
Expand Down Expand Up @@ -79,3 +80,7 @@ class ReadError(NetworkError):

class WriteError(NetworkError):
pass


class SSLError(ssl.SSLError, ConnectError):
pass

0 comments on commit f8babb3

Please sign in to comment.