Debian Codegraph @

docs/reference/exceptions.rst

raw
1 Exceptions
2 ==========
3
4 .. automodule:: websockets.exceptions
5
6 .. autoexception:: WebSocketException
7
8 Connection closed
9 -----------------
10
11 :meth:`~websockets.asyncio.connection.Connection.recv`,
12 :meth:`~websockets.asyncio.connection.Connection.send`, and similar methods
13 raise the exceptions below when the connection is closed. This is the expected
14 way to detect disconnections.
15
16 .. autoexception:: ConnectionClosed
17
18 .. autoexception:: ConnectionClosedOK
19
20 .. autoexception:: ConnectionClosedError
21
22 Connection failed
23 -----------------
24
25 These exceptions are raised by :func:`~websockets.asyncio.client.connect` when
26 the opening handshake fails and the connection cannot be established. They are
27 also reported by :func:`~websockets.asyncio.server.serve` in logs.
28
29 .. autoexception:: InvalidURI
30
31 .. autoexception:: InvalidProxy
32
33 .. autoexception:: InvalidHandshake
34
35 .. autoexception:: SecurityError
36
37 .. autoexception:: RequestLineTooLong
38
39 .. autoexception:: StatusLineTooLong
40
41 .. autoexception:: HeaderLineTooLong
42
43 .. autoexception:: TooManyHeaders
44
45 .. autoexception:: ProxyError
46
47 .. autoexception:: InvalidProxyMessage
48
49 .. autoexception:: InvalidProxyStatus
50
51 .. autoexception:: InvalidMessage
52
53 .. autoexception:: InvalidMethod
54
55 .. autoexception:: InvalidProtocol
56
57 .. autoexception:: InvalidStatus
58
59 .. autoexception:: InvalidHeader
60
61 .. autoexception:: InvalidHeaderFormat
62
63 .. autoexception:: InvalidHeaderValue
64
65 .. autoexception:: InvalidOrigin
66
67 .. autoexception:: InvalidUpgrade
68
69 .. autoexception:: NegotiationError
70
71 .. autoexception:: DuplicateParameter
72
73 .. autoexception:: InvalidParameterName
74
75 .. autoexception:: InvalidParameterValue
76
77 Sans-I/O exceptions
78 -------------------
79
80 These exceptions are only raised by the Sans-I/O implementation. They are
81 translated to :exc:`ConnectionClosedError` in the other implementations.
82
83 .. autoexception:: ProtocolError
84
85 .. autoexception:: PayloadTooBig
86
87 .. autoexception:: InvalidState
88
89 Miscellaneous exceptions
90 ------------------------
91
92 .. autoexception:: ConcurrencyError
93
94 Legacy exceptions
95 -----------------
96
97 These exceptions are only used by the legacy :mod:`asyncio` implementation.
98
99 .. autoexception:: InvalidStatusCode
100
101 .. autoexception:: AbortHandshake
102
103 .. autoexception:: RedirectHandshake