Advanced Handlers — Aquilia Documentation
Comprehensive guide and documentation for Advanced Handlers in the Aquilia framework. View API reference, examples, and implementation patterns.
FAULTS / ADVANCED TOPICS Custom Domains & Debugging Configure custom domains to group application-specific errors, and customize the HTML debug pages shown during local development. Custom Domains By default, Aquilia includes domains like FaultDomain.MODEL or FaultDomain.SECURITY. To define your own application-specific domain, use the FaultDomain.custom(name, description) factory method: from aquilia.faults import FaultDomain, Fault # 1. Instantiate custom domain BILLING_DOMAIN = FaultDomain.custom("billing", "Errors originating from the Stripe payment flows") # 2. Use the domain in a Fault instantiation raise Fault( code="PAYMENT_FAILED", message="Credit card transaction was declined by Stripe", domain=BILLING_DOMAIN, public=True, ) Development Debug Pages When running in local development mode (debug=True), unhandled Exceptions or Faults originating from HTML clients (Accept: text/html) render beautiful, interactive diagnostics: - Source Code View: Shows syntax-highlighted source code slices surrounding the line that raised the error. - Local Variables: Dumps variable values for every traceback stack frame. - Request Inspection: Displays raw ASGI scopes, headers, active cookies, and body sizes. from aquilia.debug import DebugPageRenderer # The ExceptionMiddleware instantiates the renderer automatically: renderer = DebugPageRenderer( show_locals=True, # Dump local variables in stack frames context_lines=7 # Number of surrounding lines of source code to display ) Fault Domains Cache )
Go to Homepage