|
14 | 14 |
|
15 | 15 | from .api import NodeEvent, PlugwiseNode, StickEvent |
16 | 16 | from .connection import StickController |
17 | | -from .exceptions import StickError, SubscriptionError |
| 17 | +from .exceptions import NodeError, StickError, SubscriptionError |
18 | 18 | from .network import StickNetwork |
19 | 19 |
|
20 | 20 | FuncT = TypeVar("FuncT", bound=Callable[..., Any]) |
@@ -350,15 +350,21 @@ async def register_node(self, mac: str) -> bool: |
350 | 350 | """Add node to plugwise network.""" |
351 | 351 | if self._network is None: |
352 | 352 | return False |
353 | | - return await self._network.register_node(mac) |
| 353 | + try: |
| 354 | + return await self._network.register_node(mac) |
| 355 | + except NodeError as exc: |
| 356 | + raise NodeError(f"Unable to add Node ({mac}): {exc}") from exc |
354 | 357 |
|
355 | 358 | @raise_not_connected |
356 | 359 | @raise_not_initialized |
357 | 360 | async def unregister_node(self, mac: str) -> None: |
358 | 361 | """Remove node to plugwise network.""" |
359 | 362 | if self._network is None: |
360 | 363 | return |
361 | | - await self._network.unregister_node(mac) |
| 364 | + try: |
| 365 | + await self._network.unregister_node(mac) |
| 366 | + except MessageError as exc: |
| 367 | + raise NodeError(f"Unable to remove Node ({mac}): {exc}") from exc |
362 | 368 |
|
363 | 369 | async def disconnect(self) -> None: |
364 | 370 | """Disconnect from USB-Stick.""" |
|
0 commit comments