{
  "id": "python/fastapi-http-exception-handling",
  "signature": "fastapi.exceptions.HTTPException: 404 Not Found",
  "signature_zh": "FastAPI HTTP异常：404未找到",
  "regex": "fastapi\\.exceptions\\.HTTPException:\\ 404\\ Not\\ Found",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The requested resource does not exist, and the code raises an HTTPException with status code 404.",
  "root_cause_type": "generic",
  "root_cause_zh": "请求的资源不存在，代码抛出了状态码为404的HTTPException。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Returning a generic error message without raising HTTPException",
      "why_fails": "Does not properly signal the error to the client; may cause confusion.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Catching the exception and returning a 200 status",
      "why_fails": "Misrepresents the error; client thinks the request succeeded.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Raise HTTPException with appropriate status code and message",
      "success_rate": 0.95,
      "how": "from fastapi import HTTPException\nraise HTTPException(status_code=404, detail=\"Item not found\")",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use exception handlers for custom responses",
      "success_rate": 0.9,
      "how": "@app.exception_handler(HTTPException)\nasync def http_exception_handler(request, exc):\n    return JSONResponse(status_code=exc.status_code, content={\"error\": exc.detail})",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}