Skip to main content

systemprompt_content/
error.rs

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