#[non_exhaustive]pub enum FraiseQLError {
Show 21 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,
},
ServiceUnavailable {
message: String,
retry_after: Option<u64>,
},
Auth(Box<dyn Error + Send + Sync>),
Webhook(Box<dyn Error + Send + Sync>),
Observer(Box<dyn Error + Send + Sync>),
File(FileError),
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 syntaxValidation— Schema validation failuresUnknownField— Field doesn’t exist on typeUnknownType— Type doesn’t exist in schema
§Database Errors
Database— PostgreSQL/MySQL/SQLite errors (includes SQL state code)ConnectionPool— Connection pool exhausted or unavailableTimeout— Query exceeded configured timeoutCancelled— Query was cancelled by caller
§Authorization/Security Errors
Authorization— User lacks permission for operationAuthentication— Invalid/expired JWT tokenRateLimited— 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/configurationUnsupported— 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, because the #[non_exhaustive]
attribute forces downstream crates to handle the possibility of new
variants — a wildcard arm is required even when every currently-defined
variant is enumerated:
use fraiseql_error::FraiseQLError;
fn describe(e: &FraiseQLError) -> &'static str {
// Missing wildcard arm: rejected by rustc even though it lists
// a few real variants — the `#[non_exhaustive]` attribute makes
// the enum effectively open from any downstream crate's point
// of view.
match e {
FraiseQLError::Parse { .. } => "parse",
FraiseQLError::Validation { .. } => "validation",
FraiseQLError::Database { .. } => "database",
}
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Parse
GraphQL parsing error.
Fields
Validation
GraphQL validation error.
Fields
UnknownField
Unknown field error.
Fields
UnknownType
Unknown type error.
Database
Database operation error.
Fields
ConnectionPool
Connection pool error.
Timeout
Query timeout error.
Fields
Cancelled
Query cancellation error.
Fields
Authorization
Authorization error.
Fields
Authentication
Authentication error.
RateLimited
Rate limiting error.
Fields
NotFound
Resource not found error.
Fields
Conflict
Conflict error.
Configuration
Configuration error.
Unsupported
Unsupported operation error.
The service is temporarily unavailable (e.g. tenant suspended).
Maps to HTTP 503. retry_after is the number of seconds to wait, if known.
Auth(Box<dyn Error + Send + Sync>)
An authentication or authorisation error originating from the auth subsystem.
The boxed source is the subsystem-specific error type (e.g.
fraiseql_auth::AuthError). To preserve subsystem vocabulary while
keeping fraiseql-error a leaf crate, the boxed payload is
type-erased here; subsystem crates provide their own
impl From<SubsystemError> for FraiseQLError (the sqlx pattern).
#[source] is explicit: thiserror 2.x does not auto-detect a single
tuple field as the source, and downstream chain-walkers (tracing,
miette, anyhow) rely on Error::source() returning the underlying
subsystem error rather than None.
§Pattern-matching on the inner error
Because the payload is boxed and dyn-erased, downstream match
statements cannot bind on subsystem variants directly. Recover the
concrete type via std::error::Error::source + downcast_ref:
use std::error::Error;
use fraiseql_error::FraiseQLError;
use fraiseql_auth::AuthError;
if let FraiseQLError::Auth(_) = &err {
if let Some(inner) = err.source().and_then(|s| s.downcast_ref::<AuthError>()) {
match inner {
AuthError::TokenExpired => {/* handle */},
_ => {},
}
}
}Webhook(Box<dyn Error + Send + Sync>)
A webhook-processing error originating from the webhook subsystem.
#[source] is explicit for the same reason as Self::Auth; see
that variant for the downcast_ref recovery pattern on the boxed
fraiseql_webhooks::WebhookError.
Observer(Box<dyn Error + Send + Sync>)
An observer subsystem error (event dispatch, action execution, retry exhaustion).
#[source] is explicit for the same reason as Self::Auth; see
that variant for the downcast_ref recovery pattern on the boxed
fraiseql_observers::ObserverError.
File(FileError)
A file-handling error (size limit, unsupported type, virus scan, quota).
Unlike Auth, Webhook, and Observer, the file-domain vocabulary
lives inside fraiseql-error itself (crate::FileError) because no
subsystem crate owns it — file operations are spread across
fraiseql-storage and fraiseql-server/storage.
Internal
Internal error.
Implementations§
Source§impl FraiseQLError
impl FraiseQLError
Sourcepub fn parse_at(message: impl Into<String>, location: impl Into<String>) -> Self
pub fn parse_at(message: impl Into<String>, location: impl Into<String>) -> Self
Create a parse error with location.
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Create a validation error.
Sourcepub fn validation_at(
message: impl Into<String>,
path: impl Into<String>,
) -> Self
pub fn validation_at( message: impl Into<String>, path: impl Into<String>, ) -> Self
Create a validation error with path.
Create an authorization error.
Sourcepub fn not_found(
resource_type: impl Into<String>,
identifier: impl Into<String>,
) -> Self
pub fn not_found( resource_type: impl Into<String>, identifier: impl Into<String>, ) -> Self
Create a not found error.
Sourcepub fn cancelled(query_id: impl Into<String>, reason: impl Into<String>) -> Self
pub fn cancelled(query_id: impl Into<String>, reason: impl Into<String>) -> Self
Create a cancellation error.
Sourcepub const fn is_client_error(&self) -> bool
pub const fn is_client_error(&self) -> bool
Check if this is a client error (4xx equivalent).
Derived from Self::status_code so the answer stays consistent
with the variant’s actual HTTP routing (notably for File(_), which
straddles 4xx and 5xx after F050).
Sourcepub const fn is_server_error(&self) -> bool
pub const fn is_server_error(&self) -> bool
Check if this is a server error (5xx equivalent).
Derived from Self::status_code for the same consistency reason
as Self::is_client_error.
Sourcepub const fn is_retryable(&self) -> bool
pub const fn is_retryable(&self) -> bool
Check if this error is retryable.
Sourcepub const fn status_code(&self) -> u16
pub const fn status_code(&self) -> u16
Get HTTP status code equivalent.
§Future variants
FraiseQLError is #[non_exhaustive]. The trailing _ => 500 arm
is a deliberate safety net so a new variant added without updating
this match still gets a defined (and safe) HTTP status — generic
500 Internal Server Error — rather than leaking implementation
details to the client by returning the wrong code.
Sourcepub const fn error_code(&self) -> &'static str
pub const fn error_code(&self) -> &'static str
Get error code for GraphQL response.
§Future variants
FraiseQLError is #[non_exhaustive]. The trailing _ arm returns
"INTERNAL_SERVER_ERROR" so a new variant added without updating
this match still receives a stable (if generic) error code.
Sourcepub fn unknown_field_with_suggestion(
field: impl Into<String>,
type_name: impl Into<String>,
available_fields: &[&str],
) -> Self
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.
Sourcepub fn from_postgres_code(code: &str, message: impl Into<String>) -> Self
pub fn from_postgres_code(code: &str, message: impl Into<String>) -> Self
Create a database error from PostgreSQL error code.
Sourcepub fn rate_limited_with_retry(retry_after_secs: u64) -> Self
pub fn rate_limited_with_retry(retry_after_secs: u64) -> Self
Create a rate limit error with retry information.
Sourcepub fn auth_error(reason: impl Into<String>) -> Self
pub fn auth_error(reason: impl Into<String>) -> Self
Create an authentication error with context.
Trait Implementations§
Source§impl Debug for FraiseQLError
impl Debug for FraiseQLError
Source§impl Display for FraiseQLError
impl Display for FraiseQLError
Source§impl Error for FraiseQLError
impl Error for FraiseQLError
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()