bug: add handler for failed get_data calls to make errors more verbose.

This commit is contained in:
UpstreamData
2024-01-15 14:28:39 -07:00
parent f5acf9ec62
commit 170843aae7

View File

@@ -26,6 +26,7 @@ import asyncssh
from pyasic.config import MinerConfig
from pyasic.data import Fan, HashBoard, MinerData
from pyasic.data.error_codes import MinerErrorData
from pyasic.errors import APIError
from pyasic.logger import logger
@@ -603,9 +604,13 @@ class BaseMiner(ABC):
args_to_send[arg.name] = None
except LookupError:
continue
function = getattr(self, getattr(self.data_locations, data_name).cmd)
miner_data[data_name] = await function(**args_to_send)
try:
function = getattr(self, getattr(self.data_locations, data_name).cmd)
miner_data[data_name] = await function(**args_to_send)
except Exception as e:
raise APIError(
f"Failed to call {data_name} on {self} while getting data."
) from e
return miner_data
async def get_data(