diff --git a/backend/main.py b/backend/main.py index 5e1f2dc..0a12a43 100644 --- a/backend/main.py +++ b/backend/main.py @@ -58,3 +58,16 @@ else: @app.get("/health") def health_check(): return {"status": "ok"} + +from fastapi import Request +from fastapi.responses import JSONResponse + +@app.exception_handler(Exception) +async def global_exception_handler(request: Request, exc: Exception): + import traceback + error_detail = "".join(traceback.format_exception(None, exc, exc.__traceback__)) + print(f"Global 500 Error: {error_detail}") + return JSONResponse( + status_code=500, + content={"message": "Internal Server Error", "detail": error_detail} + ) diff --git a/backend/services/youtube.py b/backend/services/youtube.py index 2976c85..eba6cc0 100644 --- a/backend/services/youtube.py +++ b/backend/services/youtube.py @@ -243,6 +243,7 @@ class YouTubeService: response = {"tracks": tracks} self.cache.set(cache_key, response, ttl_seconds=3600) return response + except Exception as e: print(f"Rec Error: {e}") return {"tracks": []}