Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hint to restore in log message #2342

Merged
merged 1 commit into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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