Skip to content

Commit

Permalink
Add hint to restore in log message (#2342)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Dec 12, 2021
1 parent 1543686 commit 83361ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom_components/hacs/hacsbase/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _load_from_storage():

await hass.async_add_executor_job(_load_from_storage)
self.logger.info("Restore done")
except (Exception, BaseException) as exception: # pylint: disable=broad-except
except BaseException as exception: # pylint: disable=broad-except
self.logger.critical(f"[{exception}] Restore Failed!", exc_info=exception)
return False
return True
Expand Down
13 changes: 11 additions & 2 deletions custom_components/hacs/helpers/functions/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from homeassistant.helpers.storage import Store
from homeassistant.util import json as json_util

from custom_components.hacs.const import VERSION_STORAGE
from ...const import VERSION_STORAGE
from ...exceptions import HacsException

from ...utils.logger import getLogger

Expand All @@ -16,7 +17,15 @@ class HACSStore(Store):

def load(self):
"""Load the data from disk if version matches."""
data = json_util.load_json(self.path)
try:
data = json_util.load_json(self.path)
except BaseException as exception: # pylint: disable=broad-except
_LOGGER.critical(
"Could not load '%s', restore it from a backup or delete the file: %s",
self.path,
exception,
)
raise HacsException(exception) from exception
if data == {} or data["version"] != self.version:
return None
return data["data"]
Expand Down

0 comments on commit 83361ad

Please sign in to comment.