pub struct GraphQLError {
pub message: String,
pub code: ErrorCode,
pub locations: Option<Vec<ErrorLocation>>,
pub path: Option<Vec<String>>,
pub extensions: Option<ErrorExtensions>,
}Expand description
GraphQL error following spec.
Fields§
§message: StringError message.
code: ErrorCodeError code for client handling.
locations: Option<Vec<ErrorLocation>>Location in query where error occurred.
path: Option<Vec<String>>Path to field that caused error.
extensions: Option<ErrorExtensions>Additional error information.
Implementations§
Source§impl GraphQLError
impl GraphQLError
Sourcepub fn with_location(self, line: usize, column: usize) -> Self
pub fn with_location(self, line: usize, column: usize) -> Self
Add location to error.
Sourcepub fn with_extensions(self, extensions: ErrorExtensions) -> Self
pub fn with_extensions(self, extensions: ErrorExtensions) -> Self
Add extensions to error.
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> Self
pub fn with_request_id(self, request_id: impl Into<String>) -> Self
Add request ID for distributed tracing.
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Validation error.
Sourcepub fn parse(message: impl Into<String>) -> Self
pub fn parse(message: impl Into<String>) -> Self
Parse error with hint for common syntax issues.
Sourcepub fn database(message: impl Into<String>) -> Self
pub fn database(message: impl Into<String>) -> Self
Database error - includes connection, timeout, and query errors.
Sourcepub fn internal(message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
Internal server error - unexpected conditions.
Sourcepub fn unauthenticated() -> Self
pub fn unauthenticated() -> Self
Unauthenticated error - authentication token is missing or invalid.
Sourcepub fn not_found(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
Not found error - requested resource does not exist.
Sourcepub fn timeout(operation: impl Into<String>) -> Self
pub fn timeout(operation: impl Into<String>) -> Self
Timeout error - operation took too long and was cancelled.
Sourcepub fn rate_limited(message: impl Into<String>) -> Self
pub fn rate_limited(message: impl Into<String>) -> Self
Rate limit error - too many requests from client.
Trait Implementations§
Source§impl Clone for GraphQLError
impl Clone for GraphQLError
Source§fn clone(&self) -> GraphQLError
fn clone(&self) -> GraphQLError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GraphQLError
impl Debug for GraphQLError
Source§impl From<GraphQLError> for ErrorResponse
impl From<GraphQLError> for ErrorResponse
Source§fn from(error: GraphQLError) -> Self
fn from(error: GraphQLError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for GraphQLError
impl RefUnwindSafe for GraphQLError
impl Send for GraphQLError
impl Sync for GraphQLError
impl Unpin for GraphQLError
impl UnwindSafe for GraphQLError
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: 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request