Skip to content

feat: global HTTPException and exception handlers #48

Closed

Description

@ZhuchkaTriplesix

Context

  • Unhandled Python exceptions in handlers/dependencies map to a generic 500 JSON. There is no way to turn ValueError → 400, NotFound → 404, etc., without hand-written try/except in every handler.
  • See Feature gaps (global exception handlers).

Direction

  • Introduce a small HTTPException (or similar) with status_code and optional detail / headers, caught in Rust dispatch (or a thin Python wrapper) before the generic 500 path.
  • Optional: register_exception_handler(exc_type, callable) for custom mapping, executed with GIL and safe error bodies (no stack traces in production by default; respect OXYROUTE_DEBUG).

Acceptance criteria

  • Pytest: raising the framework exception returns the expected status and body shape.
  • Document pattern in docs/handlers.md.

Research

  • FastAPI HTTPException + exception_handler; must stay compatible with RSGI response helpers.

Activity

  1. added this to the v0.3.0 milestone on Apr 26, 2026
  2. added a commit that references this issue on Apr 26, 2026
  3. added a commit that references this issue on Apr 26, 2026
  4. linked a pull request that will close this issuerelease: v0.2.0 hardening from dev #69on Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions