systemprompt_files/error.rs
1//! Typed error surface for the `systemprompt-files` crate.
2//!
3//! Boilerplate variants (`Repository`, `Io`, `Json`, `Yaml`, `Validation`,
4//! `NotFound`, `Config`) are injected by [`systemprompt_models::domain_error`].
5//! Database errors funnel through the canonical
6//! [`systemprompt_database::RepositoryError`] rather than `sqlx::Error`
7//! directly so the layer boundary is preserved.
8
9use systemprompt_models::domain_error;
10
11domain_error! {
12 pub enum FilesError {
13 common: [repository, io, json, yaml, validation, not_found, config],
14
15 #[error("storage error: {0}")]
16 Storage(String),
17 }
18}
19
20impl From<sqlx::Error> for FilesError {
21 fn from(err: sqlx::Error) -> Self {
22 Self::Repository(systemprompt_database::RepositoryError::from(err))
23 }
24}
25
26pub type FilesResult<T> = Result<T, FilesError>;