Skip to content

Commit

Permalink
Fallback to defaults on config update error
Browse files Browse the repository at this point in the history
Fix #231
  • Loading branch information
l0drex committed Jan 16, 2024
1 parent 378ba3f commit 94d2daf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions yin_yang/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
from abc import ABC, abstractmethod
from datetime import time
from functools import cache
from time import sleep
from typing import Union, Optional

import requests
from PySide6.QtCore import QObject
from PySide6.QtPositioning import QGeoPositionInfoSource, QGeoPositionInfo, QGeoCoordinate
from psutil import process_iter, NoSuchProcess
from suntime import Sun, SunTimeException

Expand Down Expand Up @@ -224,7 +220,12 @@ def load(self) -> None:
# check if config needs an update
# if the default values are set, the version number is below 0
if config_loaded['version'] < self.defaults['version']:
config_loaded = update_config(config_loaded, self.defaults)
try:
config_loaded = update_config(config_loaded, self.defaults)
except Exception as e:
logger.error('An error ocurred while trying to update the config. Using defaults instead.')
logger.error(e)
config_loaded = self.defaults

for pl in plugins:
pl.theme_light = config_loaded['plugins'][pl.name.lower()]['light_theme']
Expand Down

0 comments on commit 94d2daf

Please sign in to comment.