pub struct SafeErrorResponse { /* private fields */ }Expand description
Builder for creating error responses that prevent information leakage.
In production mode (default), error responses contain only safe, generic messages. In debug mode, full error details are included.
§Examples
use reinhardt_http::response::SafeErrorResponse;
use hyper::StatusCode;
// Production-safe response
let response = SafeErrorResponse::new(StatusCode::INTERNAL_SERVER_ERROR)
.build();
// Debug response with details
let response = SafeErrorResponse::new(StatusCode::BAD_REQUEST)
.with_detail("Missing required field: name")
.build();Implementations§
Source§impl SafeErrorResponse
impl SafeErrorResponse
Sourcepub fn new(status: StatusCode) -> Self
pub fn new(status: StatusCode) -> Self
Create a new SafeErrorResponse with the given HTTP status code.
Sourcepub fn with_detail(self, detail: impl Into<String>) -> Self
pub fn with_detail(self, detail: impl Into<String>) -> Self
Add a safe, client-facing detail message.
Only included for 4xx errors. Ignored for 5xx errors to prevent accidental information leakage.
Sourcepub fn with_debug_info(self, info: impl Into<String>) -> Self
pub fn with_debug_info(self, info: impl Into<String>) -> Self
Add debug information (only included when debug_mode is true).
WARNING: Only use in development environments.
Sourcepub fn with_debug_mode(self, debug: bool) -> Self
pub fn with_debug_mode(self, debug: bool) -> Self
Enable debug mode to include full error details in responses.
WARNING: Only use in development environments. Debug mode exposes internal error details that may leak sensitive information.
Auto Trait Implementations§
impl Freeze for SafeErrorResponse
impl RefUnwindSafe for SafeErrorResponse
impl Send for SafeErrorResponse
impl Sync for SafeErrorResponse
impl Unpin for SafeErrorResponse
impl UnsafeUnpin for SafeErrorResponse
impl UnwindSafe for SafeErrorResponse
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more