|
21 | 21 | from ..exceptions import CacheError, MessageError, NodeError, StickError, StickTimeout |
22 | 22 | from ..helpers.util import validate_mac |
23 | 23 | from ..messages.requests import ( |
24 | | - CirclePlusConnectRequest, |
25 | 24 | CircleMeasureIntervalRequest, |
| 25 | + CirclePlusConnectRequest, |
26 | 26 | NodePingRequest, |
27 | 27 | StickNetworkInfoRequest, |
28 | 28 | ) |
@@ -178,23 +178,29 @@ async def pair_plus_device(self, mac: str) -> None: |
178 | 178 | request = StickNetworkInfoRequest(self._controller.send, None) |
179 | 179 | info_response = await request.send() |
180 | 180 | except MessageError as exc: |
181 | | - raise NodeError(f"Pairing failed: {exc}") |
| 181 | + raise NodeError(f"Pairing failed: {exc}") from exc |
182 | 182 | if info_response is None: |
183 | | - raise NodeError("Pairing failed, StickNetworkInfoResponse is None") |
| 183 | + raise NodeError( |
| 184 | + "Pairing failed, StickNetworkInfoResponse is None" |
| 185 | + ) from None |
184 | 186 |
|
185 | 187 | # Init Stick |
186 | 188 | try: |
187 | 189 | await self._controller.initialize_stick() |
188 | 190 | except StickError as exc: |
189 | | - raise NodeError(f"Pairing failed, failed to initialize Stick: {exc}") |
| 191 | + raise NodeError( |
| 192 | + f"Pairing failed, failed to initialize Stick: {exc}" |
| 193 | + ) from exc |
190 | 194 |
|
191 | 195 | try: |
192 | 196 | request = CirclePlusConnectRequest(self._controller.send, bytes(mac, UTF8)) |
193 | 197 | response = await request.send() |
194 | 198 | except MessageError as exc: |
195 | | - raise NodeError(f"Pairing failed: {exc}") |
| 199 | + raise NodeError(f"Pairing failed: {exc}") from exc |
196 | 200 | if response is None: |
197 | | - raise NodeError("Pairing failed, CirclePlusConnectResponse is None") |
| 201 | + raise NodeError( |
| 202 | + "Pairing failed, CirclePlusConnectResponse is None" |
| 203 | + ) from None |
198 | 204 | if response.allowed.value != 1: |
199 | 205 | raise NodeError("Pairing failed, not allowed") |
200 | 206 |
|
|
0 commit comments