pub struct DebugInfo {
pub source_file: Option<String>,
pub source_line: Option<u32>,
pub function_name: Option<String>,
pub route_pattern: Option<String>,
pub handler_name: Option<String>,
pub extra: HashMap<String, String>,
}Expand description
Debug information to include in error responses when debug mode is enabled.
This struct holds diagnostic information that helps developers understand where and why an error occurred. This information should NEVER be included in production responses as it can leak sensitive implementation details.
§Fields
source_file: The file where the error originatedsource_line: The line number in the source filefunction_name: The function or handler that generated the errorroute_pattern: The matched route pattern (e.g., “/users/{id}”)handler_name: The name of the handler functionextra: Additional key-value debug information
§Example
use fastapi_core::error::DebugInfo;
let debug = DebugInfo::new()
.with_source_location("src/handlers/user.rs", 42, "get_user")
.with_route_pattern("/users/{id}")
.with_extra("user_id_received", "abc123");Fields§
§source_file: Option<String>Source file path.
source_line: Option<u32>Source line number.
function_name: Option<String>Function or handler name.
route_pattern: Option<String>Matched route pattern.
handler_name: Option<String>Handler name (may differ from function_name for wrapped handlers).
extra: HashMap<String, String>Additional debug context.
Implementations§
Source§impl DebugInfo
impl DebugInfo
Sourcepub fn with_source_location(
self,
file: impl Into<String>,
line: u32,
function: impl Into<String>,
) -> Self
pub fn with_source_location( self, file: impl Into<String>, line: u32, function: impl Into<String>, ) -> Self
Set the source location.
Sourcepub fn with_route_pattern(self, pattern: impl Into<String>) -> Self
pub fn with_route_pattern(self, pattern: impl Into<String>) -> Self
Set the route pattern.
Sourcepub fn with_handler_name(self, name: impl Into<String>) -> Self
pub fn with_handler_name(self, name: impl Into<String>) -> Self
Set the handler name.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DebugInfo
impl RefUnwindSafe for DebugInfo
impl Send for DebugInfo
impl Sync for DebugInfo
impl Unpin for DebugInfo
impl UnwindSafe for DebugInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).