#[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 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 (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
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.
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).
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).
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.
Sourcepub const fn error_code(&self) -> &'static str
pub const fn error_code(&self) -> &'static str
Get error code for GraphQL response.
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()
Source§impl From<Error> for FraiseQLError
impl From<Error> for FraiseQLError
Source§impl From<Error> for FraiseQLError
impl From<Error> for FraiseQLError
Auto Trait Implementations§
impl Freeze for FraiseQLError
impl !RefUnwindSafe for FraiseQLError
impl Send for FraiseQLError
impl Sync for FraiseQLError
impl Unpin for FraiseQLError
impl UnsafeUnpin for FraiseQLError
impl !UnwindSafe for FraiseQLError
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
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>
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>
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