I’m having a problem where I can’t catch exceptions on code that is run in the update of DataUpdateCoordinator. Here is a chunk of my code:
def foo():
raise ValueError("Testing testing testing")
class ECDataUpdateCoordinator(DataUpdateCoordinator):
...
async def _async_update_data(self):
"""Fetch data from EC."""
try:
await self._hass.async_add_executor_job(foo)
except Exception as exc:
print("Exception caught")
return self.ec_data
I never get the print happening. I always get the traceback from the exception.
In looking at the update coordinator code, I see the _async_update_data
is in a try/except block, hence catching the exceptions. Makes sense. What I don’t get is that other integrations (e.g.: Brother and Shelly) have try/except around their update. I’m assuming that they are caught and handled - I just can’t seem to catch them.
I’m missing something and it could be my assumptions that other integrations are doing the right thing.
Any suggestions or thoughts? Am I even supposed to be catching exceptions if using a DataUpdateCoordinator
?