From a83597fa88be7ac7dd5f6081d236d751cb40fe4d Mon Sep 17 00:00:00 2001 From: Jonathan Ehwald Date: Thu, 3 Jul 2025 21:54:07 +0200 Subject: [PATCH] Document exceptions raised by send_frame et al. (#11234) --- CHANGES/11234.doc.rst | 2 ++ docs/web_reference.rst | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 CHANGES/11234.doc.rst diff --git a/CHANGES/11234.doc.rst b/CHANGES/11234.doc.rst new file mode 100644 index 00000000000..900b56a771c --- /dev/null +++ b/CHANGES/11234.doc.rst @@ -0,0 +1,2 @@ +Clarified exceptions raised by ``WebSocketResponse.send_frame`` at al. +-- by :user:`DoctorJohn`. diff --git a/docs/web_reference.rst b/docs/web_reference.rst index 74e7f9cd3d1..0e62fd66dad 100644 --- a/docs/web_reference.rst +++ b/docs/web_reference.rst @@ -1087,7 +1087,9 @@ and :ref:`aiohttp-web-signals` handlers:: :class:`str` (converted to *UTF-8* encoded bytes) or :class:`bytes`. - :raise RuntimeError: if connections is not started or closing. + :raise RuntimeError: if the connections is not started. + + :raise aiohttp.ClientConnectionResetError: if the connection is closing. .. versionchanged:: 3.0 @@ -1102,7 +1104,9 @@ and :ref:`aiohttp-web-signals` handlers:: :class:`str` (converted to *UTF-8* encoded bytes) or :class:`bytes`. - :raise RuntimeError: if connections is not started or closing. + :raise RuntimeError: if the connections is not started. + + :raise aiohttp.ClientConnectionResetError: if the connection is closing. .. versionchanged:: 3.0 @@ -1119,10 +1123,12 @@ and :ref:`aiohttp-web-signals` handlers:: single message, ``None`` for not overriding per-socket setting. - :raise RuntimeError: if connection is not started or closing + :raise RuntimeError: if the connection is not started. :raise TypeError: if data is not :class:`str` + :raise aiohttp.ClientConnectionResetError: if the connection is closing. + .. versionchanged:: 3.0 The method is converted into :term:`coroutine`, @@ -1139,11 +1145,13 @@ and :ref:`aiohttp-web-signals` handlers:: single message, ``None`` for not overriding per-socket setting. - :raise RuntimeError: if connection is not started or closing + :raise RuntimeError: if the connection is not started. :raise TypeError: if data is not :class:`bytes`, :class:`bytearray` or :class:`memoryview`. + :raise aiohttp.ClientConnectionResetError: if the connection is closing. + .. versionchanged:: 3.0 The method is converted into :term:`coroutine`, @@ -1164,12 +1172,14 @@ and :ref:`aiohttp-web-signals` handlers:: returns a JSON string (:func:`json.dumps` by default). - :raise RuntimeError: if connection is not started or closing + :raise RuntimeError: if the connection is not started. :raise ValueError: if data is not serializable object :raise TypeError: if value returned by ``dumps`` param is not :class:`str` + :raise aiohttp.ClientConnectionResetError: if the connection is closing. + .. versionchanged:: 3.0 The method is converted into :term:`coroutine`, @@ -1199,6 +1209,10 @@ and :ref:`aiohttp-web-signals` handlers:: single message, ``None`` for not overriding per-socket setting. + :raise RuntimeError: if the connection is not started. + + :raise aiohttp.ClientConnectionResetError: if the connection is closing. + .. versionadded:: 3.11 .. method:: close(*, code=WSCloseCode.OK, message=b'', drain=True)