FastAPI - Error Handling
Analyze this FastAPI endpoint code:
from fastapi import FastAPI, HTTPException
app = FastAPI()
@app.get("/users/{user_id}")
async def fetch_user(user_id: int):
if user_id <= 0:
raise HTTPException(status_code=400, detail="User ID must be positive")
return {"user_id": user_id}
What is the issue with this code?