Skip to content

Commit

Permalink
Closes #149: Handling config errors
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Jan 9, 2021
1 parent 734d3ee commit de4fb48
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions skytemple/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with SkyTemple. If not, see <https://www.gnu.org/licenses/>.
import configparser
import logging
import os
from typing import Optional, Tuple, List

Expand Down Expand Up @@ -43,6 +44,7 @@
KEY_WINDOW_POS_Y = 'pos_y'

KEY_INTEGRATION_DISCORD_DISCORD_ENABLED = 'enabled'
logger = logging.getLogger(__name__)


class SkyTempleSettingsStore:
Expand All @@ -52,8 +54,11 @@ def __init__(self):
self.config_file = os.path.join(self.config_dir, CONFIG_FILE_NAME)
self.loaded_config = configparser.ConfigParser()
if os.path.exists(self.config_file):
with open_utf8(self.config_file, 'r') as f:
self.loaded_config.read_file(f)
try:
with open_utf8(self.config_file, 'r') as f:
self.loaded_config.read_file(f)
except BaseException as err:
logger.error("Error reading config, falling back to default.", exc_info=err)

def get_recent_files(self) -> List[str]:
recents = []
Expand Down

0 comments on commit de4fb48

Please sign in to comment.