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§
- Debug
Config - Debug configuration for secure debug mode access.
- Debug
Info - Debug information to include in error responses when debug mode is enabled.
- Http
Error - HTTP error that produces a response.
- Response
Validation Error - Response validation error for internal failures (500 Internal Server Error).
- Validation
Error - A single validation error item.
- Validation
Errors - 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.