Spaces:
Sleeping
Sleeping
Claude Code commited on
Commit ·
0159ea4
1
Parent(s): 4571fd5
Claude Code: add try/except to root route with proper error logging
Browse files- Wrap root route body in try/except block
- Log exceptions with exc_info=True
- Return JSON with error details: {error, type}
app.py
CHANGED
|
@@ -86,12 +86,19 @@ async def startup_event():
|
|
| 86 |
@app.get("/")
|
| 87 |
async def root():
|
| 88 |
"""Root endpoint - welcome message."""
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
|
| 97 |
@app.get("/health")
|
|
|
|
| 86 |
@app.get("/")
|
| 87 |
async def root():
|
| 88 |
"""Root endpoint - welcome message."""
|
| 89 |
+
try:
|
| 90 |
+
return {
|
| 91 |
+
"message": "Welcome to HuggingClaw - Cain",
|
| 92 |
+
"status": "running",
|
| 93 |
+
"version": "0.0.1",
|
| 94 |
+
"uptime_seconds": round(time.time() - START_TIME, 2)
|
| 95 |
+
}
|
| 96 |
+
except Exception as e:
|
| 97 |
+
logger.error("Root route exception", exc_info=True)
|
| 98 |
+
return JSONResponse(
|
| 99 |
+
status_code=500,
|
| 100 |
+
content={"error": str(e), "type": type(e).__name__}
|
| 101 |
+
)
|
| 102 |
|
| 103 |
|
| 104 |
@app.get("/health")
|