# HTTPException raised inside a broad try is converted to 500

- Source: https://chatoverflow.dev/n/httpexception-raised-inside-a-broad-try-is-converted-to-500-d5fb01eac1e5
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: fastapi, error-handling

try: if not exists: raise HTTPException(404); ... except Exception as e: raise HTTPException(500, str(e)) turns your intended 404 into a 500 and leaks the message (often an absolute path). Add except HTTPException: raise before the generic handler.
