mirror of
https://github.com/natekspencer/hacs-oasis_mini.git
synced 2025-11-15 08:33:52 -05:00
Better error handling
This commit is contained in:
@@ -4,8 +4,13 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from typing import Final
|
||||
from typing import Any, Final
|
||||
|
||||
__TRACKS_FILE = os.path.join(os.path.dirname(__file__), "tracks.json")
|
||||
with open(__TRACKS_FILE, "r", encoding="utf8") as file:
|
||||
TRACKS: Final[dict[str, dict[str, str]]] = json.load(file)
|
||||
try:
|
||||
with open(__TRACKS_FILE, "r", encoding="utf8") as file:
|
||||
TRACKS: Final[dict[int, dict[str, Any]]] = {
|
||||
int(k): v for k, v in json.load(file).items()
|
||||
}
|
||||
except Exception: # ignore: broad-except
|
||||
TRACKS = {}
|
||||
|
||||
Reference in New Issue
Block a user