Skip to content

Commit

Permalink
[Python] Use to_exception() to convert PyChipError to ChipStackError
Browse files Browse the repository at this point in the history
  • Loading branch information
agners committed Jun 17, 2024
1 parent 3842159 commit 1529942
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/controller/python/chip/clusters/Attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1529942

Please sign in to comment.