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//!
9//! Copyright (c) systemprompt.io — Business Source License 1.1.
10//! See <https://systemprompt.io> for licensing details.
11
12use systemprompt_models::domain_error;
13
14domain_error! {
15 pub enum FilesError {
16 common: [repository, io, json, yaml, validation, not_found, config],
17
18 #[error("storage error: {0}")]
19 Storage(String),
20 }
21}
22
23impl From<sqlx::Error> for FilesError {
24 fn from(err: sqlx::Error) -> Self {
25 Self::Repository(systemprompt_database::RepositoryError::from(err))
26 }
27}
28
29pub type FilesResult<T> = Result<T, FilesError>;