Skip to main content

systemprompt_content/
error.rs

1//! Typed error surface for the content crate.
2
3use systemprompt_models::domain_error;
4
5domain_error! {
6    pub enum ContentError {
7        common: [repository, io, json, yaml, validation],
8
9        #[error("database must be PostgreSQL")]
10        DatabaseNotPostgres,
11
12        #[error("content not found: {0}")]
13        ContentNotFound(String),
14
15        #[error("link not found: {0}")]
16        LinkNotFound(String),
17
18        #[error("invalid request: {0}")]
19        InvalidRequest(String),
20
21        #[error("parse error: {0}")]
22        Parse(String),
23
24        #[error("service error: {0}")]
25        Service(String),
26    }
27}
28
29impl From<sqlx::Error> for ContentError {
30    fn from(err: sqlx::Error) -> Self {
31        Self::Repository(systemprompt_database::RepositoryError::from(err))
32    }
33}
34
35pub type ContentResult<T> = Result<T, ContentError>;