diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index 5bb8e7c8eebbc7..36f5a794f9e73e 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -651,7 +651,7 @@ def __init__(self, future: Future, eventLoop, devCtrl, returnClusterObject: bool self._changedPathSet = set() self._pReadClient = None self._pReadCallback = None - self._resultError = None + self._resultError: Optional[PyChipError] = None def SetClientObjPointers(self, pReadClient, pReadCallback): self._pReadClient = pReadClient @@ -718,7 +718,7 @@ def handleEventData(self, header: EventHeader, path: EventPath, data: bytes, sta logging.exception(ex) def handleError(self, chipError: PyChipError): - self._resultError = chipError.code + self._resultError = chipError def _handleSubscriptionEstablished(self, subscriptionId): if not self._future.done(): @@ -777,11 +777,11 @@ def _handleDone(self): # move on, possibly invalidating the provided _event_loop. # if not self._future.done(): - if self._resultError: + if self._resultError is not None: if self._subscription_handler: - self._subscription_handler.OnErrorCb(self._resultError, self._subscription_handler) + self._subscription_handler.OnErrorCb(self._resultError.code, self._subscription_handler) else: - self._future.set_exception(chip.exceptions.ChipStackError(self._resultError)) + self._future.set_exception(self._resultError.to_exception()) else: self._future.set_result(AsyncReadTransaction.ReadResponse( attributes=self._cache.attributeCache, events=self._events, tlvAttributes=self._cache.attributeTLVCache)) @@ -809,7 +809,7 @@ def __init__(self, future: Future, eventLoop): self._event_loop = eventLoop self._future = future self._resultData = [] - self._resultError = None + self._resultError: Optional[PyChipError] = None def handleResponse(self, path: AttributePath, status: int): try: