Skip to main content

FraiseQLError

Enum FraiseQLError 

Source
#[non_exhaustive]
pub enum FraiseQLError {
Show 16 variants Parse { message: String, location: String, }, Validation { message: String, path: Option<String>, }, UnknownField { field: String, type_name: String, }, UnknownType { type_name: String, }, Database { message: String, sql_state: Option<String>, }, ConnectionPool { message: String, }, Timeout { timeout_ms: u64, query: Option<String>, }, Cancelled { query_id: String, reason: String, }, Authorization { message: String, action: Option<String>, resource: Option<String>, }, Authentication { message: String, }, RateLimited { message: String, retry_after_secs: u64, }, NotFound { resource_type: String, identifier: String, }, Conflict { message: String, }, Configuration { message: String, }, Unsupported { message: String, }, Internal { message: String, source: Option<Box<dyn Error + Send + Sync>>, },
}
Expand description

Main error type for FraiseQL operations.

All errors in the core library are converted to this type. Language bindings convert this to their native error types.

§Error Categories

Errors are organized by domain:

§GraphQL Errors

  • Parse — Malformed GraphQL syntax
  • Validation — Schema validation failures
  • UnknownField — Field doesn’t exist on type
  • UnknownType — Type doesn’t exist in schema

§Database Errors

  • Database — PostgreSQL/MySQL/SQLite errors (includes SQL state code)
  • ConnectionPool — Connection pool exhausted or unavailable
  • Timeout — Query exceeded configured timeout
  • Cancelled — Query was cancelled by caller

§Authorization/Security Errors

  • Authorization — User lacks permission for operation
  • Authentication — Invalid/expired JWT token
  • RateLimited — Too many requests (includes retry-after)

§Resource Errors

  • NotFound — Resource doesn’t exist (404)
  • Conflict — Operation would violate constraints (409)

§Configuration Errors

  • Configuration — Invalid setup/configuration
  • Unsupported — Operation not supported by current database backend

§Internal Errors

  • Internal — Unexpected internal failures

§Stability

This enum is marked #[non_exhaustive] to allow adding new error variants in future minor versions without breaking backward compatibility.

External match expressions must include a wildcard _ arm:

use fraiseql_error::FraiseQLError;

fn describe(e: &FraiseQLError) -> &'static str {
    match e {
        FraiseQLError::Parse { .. } => "parse error",
        FraiseQLError::Validation { .. } => "validation error",
        _ => "other error", // required: FraiseQLError is #[non_exhaustive]
    }
}

The following would not compile (missing wildcard arm):

use fraiseql_error::FraiseQLError;

fn describe(e: &FraiseQLError) -> &'static str {
    match e {
        FraiseQLError::Parse { .. } => "parse",
        FraiseQLError::Validation { .. } => "validation",
        FraiseQLError::Database { .. } => "database",
        FraiseQLError::Network { .. } => "network",
        FraiseQLError::Authorization { .. } => "authorization",
        FraiseQLError::NotFound { .. } => "not found",
        FraiseQLError::Conflict { .. } => "conflict",
        FraiseQLError::Configuration { .. } => "configuration",
        FraiseQLError::Unsupported { .. } => "unsupported",
        FraiseQLError::Internal { .. } => "internal",
        FraiseQLError::UnknownField { .. } => "unknown field",
        FraiseQLError::UnknownType { .. } => "unknown type",
        FraiseQLError::FieldExclusion { .. } => "field exclusion",
        FraiseQLError::TypeMismatch { .. } => "type mismatch",
        FraiseQLError::RateLimitExceeded { .. } => "rate limit",
        FraiseQLError::Forbidden { .. } => "forbidden",
    }
}

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Parse

GraphQL parsing error.

Fields

§message: String

Error message describing the parse failure.

§location: String

Location in the query where the error occurred.

§

Validation

GraphQL validation error.

Fields

§message: String

Error message describing the validation failure.

§path: Option<String>

Path to the field with the error (e.g., “user.posts.0.title”).

§

UnknownField

Unknown field error.

Fields

§field: String

The field name that was not found.

§type_name: String

The type on which the field was queried.

§

UnknownType

Unknown type error.

Fields

§type_name: String

The type name that was not found.

§

Database

Database operation error.

Fields

§message: String

Error message from the database.

§sql_state: Option<String>

SQL state code if available (e.g., “23505” for unique violation).

§

ConnectionPool

Connection pool error.

Fields

§message: String

Error message.

§

Timeout

Query timeout error.

Fields

§timeout_ms: u64

Timeout duration in milliseconds.

§query: Option<String>

The query that timed out (truncated if too long).

§

Cancelled

Query cancellation error.

Fields

§query_id: String

Query identifier for tracking/logging.

§reason: String

Reason for cancellation.

§

Authorization

Authorization error.

Fields

§message: String

Error message.

§action: Option<String>

The action that was denied.

§resource: Option<String>

The resource that was being accessed.

§

Authentication

Authentication error.

Fields

§message: String

Error message.

§

RateLimited

Rate limiting error.

Fields

§message: String

Error message.

§retry_after_secs: u64

Number of seconds to wait before retrying.

§

NotFound

Resource not found error.

Fields

§resource_type: String

Type of resource (e.g., “User”, “Post”).

§identifier: String

Identifier that was looked up.

§

Conflict

Conflict error.

Fields

§message: String

Error message.

§

Configuration

Configuration error.

Fields

§message: String

Error message.

§

Unsupported

Unsupported operation error.

Fields

§message: String

Error message describing what is not supported.

§

Internal

Internal error.

Fields

§message: String

Error message.

§source: Option<Box<dyn Error + Send + Sync>>

Optional source error for debugging.

Implementations§

Source§

impl FraiseQLError

Source

pub fn parse(message: impl Into<String>) -> Self

Create a parse error.

Source

pub fn parse_at(message: impl Into<String>, location: impl Into<String>) -> Self

Create a parse error with location.

Source

pub fn validation(message: impl Into<String>) -> Self

Create a validation error.

Source

pub fn validation_at( message: impl Into<String>, path: impl Into<String>, ) -> Self

Create a validation error with path.

Source

pub fn database(message: impl Into<String>) -> Self

Create a database error.

Source

pub fn unauthorized(message: impl Into<String>) -> Self

Create an authorization error.

Source

pub fn not_found( resource_type: impl Into<String>, identifier: impl Into<String>, ) -> Self

Create a not found error.

Source

pub fn config(message: impl Into<String>) -> Self

Create a configuration error.

Source

pub fn internal(message: impl Into<String>) -> Self

Create an internal error.

Source

pub fn cancelled(query_id: impl Into<String>, reason: impl Into<String>) -> Self

Create a cancellation error.

Source

pub const fn is_client_error(&self) -> bool

Check if this is a client error (4xx equivalent).

Source

pub const fn is_server_error(&self) -> bool

Check if this is a server error (5xx equivalent).

Source

pub const fn is_retryable(&self) -> bool

Check if this error is retryable.

Source

pub const fn status_code(&self) -> u16

Get HTTP status code equivalent.

Source

pub const fn error_code(&self) -> &'static str

Get error code for GraphQL response.

Source

pub fn unknown_field_with_suggestion( field: impl Into<String>, type_name: impl Into<String>, available_fields: &[&str], ) -> Self

Create an unknown field error with helpful suggestions.

Source

pub fn from_postgres_code(code: &str, message: impl Into<String>) -> Self

Create a database error from PostgreSQL error code.

Source

pub fn rate_limited_with_retry(retry_after_secs: u64) -> Self

Create a rate limit error with retry information.

Source

pub fn auth_error(reason: impl Into<String>) -> Self

Create an authentication error with context.

Trait Implementations§

Source§

impl Debug for FraiseQLError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for FraiseQLError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for FraiseQLError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for FraiseQLError

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for FraiseQLError

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<VarError> for FraiseQLError

Source§

fn from(e: VarError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more