pub struct ErrorSanitizer { /* private fields */ }Expand description
Sanitizes GraphQL errors before they reach the client.
When configured with enabled = true, strips internal details from
DatabaseError and InternalServerError responses. Client-facing error
codes (validation, auth, not-found, etc.) are always passed through
unchanged so the client can act on them.
Implementations§
Source§impl ErrorSanitizer
impl ErrorSanitizer
Sourcepub const fn new(config: ErrorSanitizationConfig) -> Self
pub const fn new(config: ErrorSanitizationConfig) -> Self
Create a new sanitizer with the given configuration.
Sourcepub fn sanitize(&self, error: GraphQLError) -> GraphQLError
pub fn sanitize(&self, error: GraphQLError) -> GraphQLError
Sanitize a single GraphQL error.
Returns the error unchanged when:
- sanitization is disabled, or
- the error code is client-facing (validation, auth, not-found, etc.)
Sourcepub fn sanitize_all(&self, errors: Vec<GraphQLError>) -> Vec<GraphQLError>
pub fn sanitize_all(&self, errors: Vec<GraphQLError>) -> Vec<GraphQLError>
Sanitize a batch of errors (the GraphQL errors response array).
Sourcepub const fn is_enabled(&self) -> bool
pub const fn is_enabled(&self) -> bool
Whether sanitization is enabled.
Auto Trait Implementations§
impl Freeze for ErrorSanitizer
impl RefUnwindSafe for ErrorSanitizer
impl Send for ErrorSanitizer
impl Sync for ErrorSanitizer
impl Unpin for ErrorSanitizer
impl UnsafeUnpin for ErrorSanitizer
impl UnwindSafe for ErrorSanitizer
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