Commit 14d34e8
committed
aioble/l2cap: Convert OSError EINVAL to L2CAPDisconnectedError
When the BLE peer disconnects during an L2CAP transfer, ble.l2cap_send(),
ble.l2cap_recvinto(), and ble.l2cap_disconnect() raise OSError with errno
EINVAL because the connection handle or CID is no longer valid.
Callers catch L2CAPDisconnectedError (now a DeviceDisconnectedError
subclass) for clean disconnect handling, but the raw OSError was not
being converted — it fell through to generic exception handlers.
Wrap all three call sites:
- send(): catch OSError EINVAL, raise L2CAPDisconnectedError
- recvinto(): catch OSError EINVAL, raise L2CAPDisconnectedError
- disconnect(): catch OSError EINVAL, set _cid = None, return cleanly1 parent a51c737 commit 14d34e8
1 file changed
+29
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | | - | |
| 122 | + | |
| 123 | + | |
122 | 124 | | |
123 | | - | |
124 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
125 | 133 | | |
126 | 134 | | |
127 | 135 | | |
| |||
141 | 149 | | |
142 | 150 | | |
143 | 151 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
149 | 162 | | |
150 | 163 | | |
151 | 164 | | |
| |||
161 | 174 | | |
162 | 175 | | |
163 | 176 | | |
164 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
165 | 185 | | |
166 | 186 | | |
167 | 187 | | |
| |||
0 commit comments