Skip to content

src/dazzle_back/runtime/exception_handlers.py

Generated: 2026-03-30T04:38:47.186206+00:00

Commit: 615f1354a103

Language: python

Scope: dazzle_back

Purpose

Exception handlers for DNR-Back applications.

Provides centralized exception handling for: - State machine transition errors - Invariant violations - Pydantic validation errors - Custom 404 pages for site rendering

HTMX-aware: when HX-Request header is present, validation errors return rendered HT...

Key Exports

  • register_exception_handlers
  • register_site_error_handlers
  • constraint_violation_handler
  • transition_error_handler
  • invariant_error_handler
  • validation_error_handler
  • custom_http_error_handler

Dependencies

Imports

  • pathlib.Path
  • typing.Any
  • fastapi.FastAPI
  • fastapi.responses.Response
  • fastapi.Request
  • fastapi.responses.JSONResponse
  • pydantic.ValidationError
  • dazzle_back.runtime.htmx_response.HtmxDetails
  • dazzle_back.runtime.htmx_response.json_or_htmx_error
  • dazzle_back.runtime.invariant_evaluator.InvariantViolationError
  • dazzle_back.runtime.repository.ConstraintViolationError
  • dazzle_back.runtime.state_machine.TransitionError
  • starlette.exceptions.HTTPException
  • dazzle_ui.runtime.site_context.build_site_404_context
  • dazzle_ui.runtime.site_context.build_site_error_context
  • dazzle_ui.runtime.template_renderer.render_site_page
  • fastapi.responses.HTMLResponse
  • fastapi.responses.JSONResponse

Event Interactions

None detected.

Invariants and Assumptions

No invariants documented.

Tests

  • tests/unit/test_exception_handlers.py
  • tests/integration/test_runtime_e2e.py
  • tests/integration/test_runtime_pipeline.py
  • tests/unit/test_runtime_test_routes.py
  • tests/unit/test_runtime_services.py

Notes

This page was automatically generated by tools/gen_reference_docs.py.