feat(src/services): improve error handlingwith detailed logging
Replace silent exception swallowing with explicit logging via logger.error to aid debugging and observability
This commit is contained in:
5 files changed
+27
-25
No files matched your search
@@ -1,3 +1,5 @@
|
||||
from fabric.utils import logger
|
||||
|
||||
# Standard library imports
|
||||
import json
|
||||
import uuid
|
||||
@@ -36,7 +38,7 @@ class TodoService(Service):
|
||||
try:
|
||||
callback(event_type, data)
|
||||
except Exception as e:
|
||||
print(f"Error in todo callback: {e}")
|
||||
logger.error(f"Error in todo callback: {e}")
|
||||
|
||||
def _get_todos_file_path(self):
|
||||
"""Returns the path to the todos JSON file"""
|
||||
@@ -53,7 +55,7 @@ class TodoService(Service):
|
||||
else:
|
||||
self._todos = []
|
||||
except Exception as e:
|
||||
print(f"Error loading todos: {e}")
|
||||
logger.error(f"Error loading todos: {e}")
|
||||
self._todos = []
|
||||
|
||||
def _save_todos(self):
|
||||
@@ -62,7 +64,7 @@ class TodoService(Service):
|
||||
with open(self._file_path, "w", encoding="utf-8") as f:
|
||||
json.dump(self._todos, f, indent=2, ensure_ascii=False)
|
||||
except Exception as e:
|
||||
print(f"Error saving todos: {e}")
|
||||
logger.error(f"Error saving todos: {e}")
|
||||
|
||||
@Property(list, "readable")
|
||||
def todos(self):
|
||||
|
||||
Reference in new issue
Block a user