Skip to content

Commit

Permalink
Fixed load error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hui committed Mar 2, 2023
1 parent d765a64 commit ad20d47
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions e4e_data_management/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ def load(cls, *, config_dir: Optional[Path] = None) -> DataManager:
Returns:
DataManager: restored application
"""
if config_dir is None:
config_dir = cls.config_dir
config_file = config_dir.joinpath(cls.__CONFIG_NAME)
if not config_file.exists():
try:
if config_dir is None:
config_dir = cls.config_dir
config_file = config_dir.joinpath(cls.__CONFIG_NAME)
if not config_file.exists():
return DataManager(app_config_dir=config_dir)
with open(config_file, 'rb') as handle:
return pickle.load(handle)
except Exception: # pylint: disable=broad-except
return DataManager(app_config_dir=config_dir)
with open(config_file, 'rb') as handle:
return pickle.load(handle)

def save(self) -> None:
"""Saves the app into the specified config dir
Expand Down

0 comments on commit ad20d47

Please sign in to comment.