pub enum GraphQLError {
Show 15 variants
ExecutionError(String),
SchemaBuildError(String),
RequestHandlingError(String),
SerializationError(String),
JsonError(String),
ValidationError(String),
ParseError(String),
AuthenticationError(String),
AuthorizationError(String),
NotFound(String),
RateLimitExceeded(String),
InvalidInput {
message: String,
},
ComplexityLimitExceeded,
DepthLimitExceeded,
InternalError(String),
}Expand description
Errors that can occur during GraphQL operations
These errors are compatible with async-graphql error handling and can be converted to structured HTTP responses matching the project’s error fixtures.
Variants§
ExecutionError(String)
Error during schema execution
Occurs when the GraphQL executor encounters a runtime error during query execution.
SchemaBuildError(String)
Error during schema building
Occurs when schema construction fails due to invalid definitions or conflicts.
RequestHandlingError(String)
Error during request handling
Occurs when the HTTP request cannot be properly handled or parsed.
SerializationError(String)
Serialization error
Occurs during JSON serialization/deserialization of GraphQL values.
JsonError(String)
JSON parsing error
Occurs when JSON input cannot be parsed.
ValidationError(String)
GraphQL validation error
Occurs when a GraphQL query fails schema validation.
ParseError(String)
GraphQL parse error
Occurs when the GraphQL query string cannot be parsed.
AuthenticationError(String)
Authentication error
Occurs when request authentication fails.
AuthorizationError(String)
Authorization error
Occurs when user lacks required permissions.
NotFound(String)
Not found error
Occurs when a requested resource is not found.
RateLimitExceeded(String)
Rate limit error
Occurs when rate limit is exceeded.
InvalidInput
Invalid input error with validation details
Occurs during input validation with detailed error information.
ComplexityLimitExceeded
Query complexity limit exceeded
Occurs when a GraphQL query exceeds the configured complexity limit.
DepthLimitExceeded
Query depth limit exceeded
Occurs when a GraphQL query exceeds the configured depth limit.
InternalError(String)
Internal server error
Occurs when an unexpected internal error happens.
Implementations§
Source§impl GraphQLError
impl GraphQLError
Sourcepub const fn status_code(&self) -> u16
pub const fn status_code(&self) -> u16
Convert error to HTTP status code
Maps GraphQL error types to appropriate HTTP status codes:
- 400: Bad Request for parse/request-handling errors
- 401: Unauthorized for authentication errors
- 403: Forbidden for authorization errors
- 404: Not Found for resource not found
- 422: Unprocessable Entity for validation failures
- 429: Too Many Requests for rate limit errors
- 500: Internal Server Error for schema/serialization/internal errors
- 200: OK for GraphQL execution errors returned in GraphQL response body
§Examples
use spikard_graphql::error::GraphQLError;
let error = GraphQLError::AuthenticationError("Invalid token".to_string());
assert_eq!(error.status_code(), 401);
let error = GraphQLError::ExecutionError("Query failed".to_string());
assert_eq!(error.status_code(), 200); // GraphQL spec: errors return 200 with errors in bodySourcepub fn to_graphql_response(&self) -> Value
pub fn to_graphql_response(&self) -> Value
Convert error to GraphQL error response JSON
Returns a JSON object matching the GraphQL spec error format with structured extensions for HTTP integration.
§Format
{
"errors": [
{
"message": "error message",
"extensions": {
"code": "ERROR_CODE",
"status": 400,
"type": "https://spikard.dev/errors/..."
}
}
]
}§Examples
use spikard_graphql::error::GraphQLError;
let error = GraphQLError::ValidationError("Invalid query".to_string());
let json = error.to_graphql_response();
assert!(json["errors"].is_array());Sourcepub fn to_http_response(&self) -> Value
pub fn to_http_response(&self) -> Value
Convert error to structured HTTP error response
Returns a JSON object matching the project’s error fixture format, suitable for direct HTTP response conversion.
§Format
{
"type": "https://spikard.dev/errors/...",
"title": "Error Title",
"status": 422,
"detail": "error message",
"errors": [
{
"type": "error_code",
"message": "error message"
}
]
}§Examples
use spikard_graphql::error::GraphQLError;
let error = GraphQLError::ValidationError("Invalid query".to_string());
let json = error.to_http_response();
assert_eq!(json["status"], 422);Sourcepub const fn is_transient(&self) -> bool
pub const fn is_transient(&self) -> bool
Whether the error condition is transient and may succeed on retry.
Returns true for upstream/infrastructure failures (rate limit, internal error) and false for client-input errors (validation, parse, auth). Bindings forward this signal to retry/back-off logic.
Sourcepub const fn error_type(&self) -> &'static str
pub const fn error_type(&self) -> &'static str
Stable machine-readable error type identifier (SCREAMING_SNAKE_CASE).
Public alias for the same codes returned by Self::error_code, kept
available to bindings that surface the identifier alongside the
human-readable message.
Sourcepub const fn error_code(&self) -> &'static str
pub const fn error_code(&self) -> &'static str
Get the error code suitable for machine parsing
Returns a screaming SNAKE_CASE error code that identifies the error type.
Trait Implementations§
Source§impl Clone for GraphQLError
impl Clone for GraphQLError
Source§fn clone(&self) -> GraphQLError
fn clone(&self) -> GraphQLError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GraphQLError
impl Debug for GraphQLError
Source§impl<'de> Deserialize<'de> for GraphQLError
impl<'de> Deserialize<'de> for GraphQLError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for GraphQLError
impl Display for GraphQLError
Source§impl Error for GraphQLError
impl Error for GraphQLError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for GraphQLError
impl RefUnwindSafe for GraphQLError
impl Send for GraphQLError
impl Sync for GraphQLError
impl Unpin for GraphQLError
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);