Skip to content
Snippets Groups Projects
Verified Commit 5f61a1f5 authored by Ole Binder's avatar Ole Binder
Browse files

Feat: improve exception handling

parent ca41d3d1
No related branches found
No related tags found
1 merge request!46Steering playout schema and virtual timeslot integration
Pipeline #8609 passed
......@@ -125,12 +125,25 @@ class TimetableService:
"""
Stores the current timetable to the local JSON file used for caching.
"""
if self.timetable_file is None:
self.logger.error(SU.red("No timetable file specified."))
return
# Ensure the directory exists
os.makedirs(os.path.dirname(self.timetable_file), exist_ok=True)
try:
with open(self.timetable_file, "w") as file:
file.write(jsonpickle.encode(self.timetable, unpicklable=self.restorable))
self.logger.info(SU.green("timetable.json stored"))
except FileNotFoundError as fnf_error:
self.logger.error(SU.red(f"File not found: {self.timetable_file}. {fnf_error}"))
except PermissionError as perm_error:
self.logger.error(
SU.red(f"Permission denied for file: {self.timetable_file}. {perm_error}")
)
except Exception as e:
self.logger.error(SU.red(f"Error while storing {self.timetable_file}"), e)
self.logger.error(SU.red(f"Unexpected error while storing {self.timetable_file}: {e}"))
def get_current_item(self) -> PlaylistItem | None:
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment