mirror of https://github.com/Andre0512/pyhOn.git
Improve error handling
This commit is contained in:
parent
e234ef3bbb
commit
3d5c8405ea
|
@ -109,7 +109,7 @@ class HonAppliance:
|
||||||
@property
|
@property
|
||||||
def nick_name(self) -> str:
|
def nick_name(self) -> str:
|
||||||
result = self._check_name_zone("nickName")
|
result = self._check_name_zone("nickName")
|
||||||
if not result or re.findall("^[xX1\\s]+$", result):
|
if not result or re.findall("^[xX1\\s-]+$", result):
|
||||||
return self.model_name
|
return self.model_name
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -267,8 +267,13 @@ class TestAPI(HonAPI):
|
||||||
_LOGGER.warning("Can't open %s", str(path))
|
_LOGGER.warning("Can't open %s", str(path))
|
||||||
return {}
|
return {}
|
||||||
with open(path, "r", encoding="utf-8") as json_file:
|
with open(path, "r", encoding="utf-8") as json_file:
|
||||||
data: Dict[str, Any] = json.loads(json_file.read())
|
text = json_file.read()
|
||||||
|
try:
|
||||||
|
data: Dict[str, Any] = json.loads(text)
|
||||||
return data
|
return data
|
||||||
|
except json.decoder.JSONDecodeError as error:
|
||||||
|
_LOGGER.error("%s - %s", str(path), error)
|
||||||
|
return {}
|
||||||
|
|
||||||
async def load_appliances(self) -> List[Dict[str, Any]]:
|
async def load_appliances(self) -> List[Dict[str, Any]]:
|
||||||
result = []
|
result = []
|
||||||
|
|
Loading…
Reference in New Issue