fraiseql_error/lib.rs
1//! Unified error types for FraiseQL runtime crates.
2//!
3//! All runtime crates depend on this crate for error handling.
4//!
5//! # Canonical taxonomy
6//!
7//! [`FraiseQLError`] is the single root error type for the FraiseQL workspace.
8//! It is built around two layers:
9//!
10//! 1. **Engine variants** (`Parse`, `Validation`, `Database`, `RateLimited`, `NotFound`,
11//! `ServiceUnavailable`, `Internal`, …) which the core and runtime crates raise directly.
12//! 2. **Domain composition variants** (`Auth`, `Webhook`, `Observer`, `File`) which wrap subsystem
13//! error types via `From` impls owned by each subsystem crate (sqlx pattern). This lets
14//! `fraiseql-error` stay a leaf crate while still exposing one unified taxonomy.
15//!
16//! With the `axum-compat` feature enabled, [`FraiseQLError`] also implements
17//! [`axum::response::IntoResponse`] so handlers can return
18//! `Result<_, FraiseQLError>` directly; the conversion produces an
19//! [`ErrorResponse`] JSON body with the appropriate HTTP status code.
20//!
21//! ```text
22//! FraiseQLError
23//! ↓ IntoResponse (via fraiseql-error::http, feature `axum-compat`)
24//! ErrorResponse { error, error_description, error_code, error_uri, details, retry_after }
25//! ↓ Json(response) + StatusCode
26//! HTTP response body (application/json)
27//! ```
28//!
29//! ## Security note
30//!
31//! All variants that might leak internal details (database messages, config values,
32//! provider endpoints) return **generic** descriptions in the HTTP response body.
33//! Raw error details are available only in structured server logs.
34
35#![warn(missing_docs)]
36// Wave 9 (Q4): pilot crate for the workspace `clippy::indexing_slicing` rollout.
37// All library code is panic-free w.r.t. slice/vec indexing; the lint is denied
38// here at the crate level. Test files opt out individually with a `Reason:`.
39#![deny(clippy::indexing_slicing)]
40
41mod config;
42pub mod core_error;
43mod file;
44pub mod graphql_error;
45#[cfg(feature = "axum-compat")]
46mod http;
47
48pub use config::ConfigError;
49pub use core_error::{ErrorContext, FraiseQLError, Result, ValidationFieldError};
50pub use file::FileError;
51pub use graphql_error::{GraphQLError, GraphQLErrorLocation};
52// Re-export for convenience — only available with the `axum-compat` feature
53#[cfg(feature = "axum-compat")]
54pub use http::{ErrorResponse, IntoHttpResponse};