Skip to content

Commit 89dcb44

Browse files
committed
[Python] Use to_exception() to convert PyChipError to ChipStackError
1 parent 8644738 commit 89dcb44

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/controller/python/chip/clusters/Attribute.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ def __init__(self, future: Future, eventLoop, devCtrl, returnClusterObject: bool
651651
self._changedPathSet = set()
652652
self._pReadClient = None
653653
self._pReadCallback = None
654-
self._resultError = None
654+
self._resultError: Optional[PyChipError] = None
655655

656656
def SetClientObjPointers(self, pReadClient, pReadCallback):
657657
self._pReadClient = pReadClient
@@ -718,7 +718,7 @@ def handleEventData(self, header: EventHeader, path: EventPath, data: bytes, sta
718718
logging.exception(ex)
719719

720720
def handleError(self, chipError: PyChipError):
721-
self._resultError = chipError.code
721+
self._resultError = chipError
722722

723723
def _handleSubscriptionEstablished(self, subscriptionId):
724724
if not self._future.done():
@@ -777,11 +777,11 @@ def _handleDone(self):
777777
# move on, possibly invalidating the provided _event_loop.
778778
#
779779
if not self._future.done():
780-
if self._resultError:
780+
if self._resultError is not None:
781781
if self._subscription_handler:
782-
self._subscription_handler.OnErrorCb(self._resultError, self._subscription_handler)
782+
self._subscription_handler.OnErrorCb(self._resultError.code, self._subscription_handler)
783783
else:
784-
self._future.set_exception(chip.exceptions.ChipStackError(self._resultError))
784+
self._future.set_exception(self._resultError.to_exception())
785785
else:
786786
self._future.set_result(AsyncReadTransaction.ReadResponse(
787787
attributes=self._cache.attributeCache, events=self._events, tlvAttributes=self._cache.attributeTLVCache))
@@ -809,7 +809,7 @@ def __init__(self, future: Future, eventLoop):
809809
self._event_loop = eventLoop
810810
self._future = future
811811
self._resultData = []
812-
self._resultError = None
812+
self._resultError: Optional[PyChipError] = None
813813

814814
def handleResponse(self, path: AttributePath, status: int):
815815
try:

0 commit comments

Comments
 (0)