Skip to main content

Module error

Module error 

Source
Expand description

Error types.

This module provides error types for HTTP responses with support for debug mode that can include additional diagnostic information.

§Debug Mode

Debug mode can be enabled to include additional diagnostic information in error responses:

  • Source location (file, line, function)
  • Full validation error context
  • Handler name and route pattern

Debug mode is controlled per-error via the with_debug_info method, and should only be enabled when the application is in debug mode AND the request includes a valid debug token (if configured).

§Example

use fastapi_core::error::{HttpError, DebugInfo};

// Production mode - no debug info
let error = HttpError::not_found().with_detail("User not found");

// Debug mode - with source location
let error = HttpError::not_found()
    .with_detail("User not found")
    .with_debug_info(DebugInfo::new()
        .with_source_location(file!(), line!(), "get_user")
        .with_route_pattern("/users/{id}"));

Modules§

error_types
Common validation error type strings (matching Pydantic v2).
loc
Location prefixes for different extraction sources.

Structs§

DebugConfig
Debug configuration for secure debug mode access.
DebugInfo
Debug information to include in error responses when debug mode is enabled.
HttpError
HTTP error that produces a response.
ResponseValidationError
Response validation error for internal failures (500 Internal Server Error).
ValidationError
A single validation error item.
ValidationErrors
Collection of validation errors (422 Unprocessable Entity response).

Enums§

LocItem
Location item for validation error paths.

Functions§

disable_debug_mode
Disable debug mode globally.
enable_debug_mode
Enable debug mode globally.
is_debug_mode_enabled
Check if debug mode is enabled globally.