Skip to main content

systemprompt_evaluation/
error.rs

1//! Typed error boundary for the `systemprompt-evaluation` 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 EvaluationError {
10        common: [repository, json],
11
12        #[error("AI provider request failed: {0}")]
13        Ai(String),
14
15        #[error("Run not found: {0}")]
16        RunNotFound(String),
17
18        #[error("Rubric not found: {0}")]
19        RubricNotFound(String),
20
21        #[error("Judge verdict unparseable: {0}")]
22        JudgeParse(String),
23
24        #[error("Replay source incomplete: {0}")]
25        ReplaySource(String),
26
27        #[error("Budget exhausted: spent {spent} of {budget} microdollars")]
28        BudgetExhausted { spent: i64, budget: i64 },
29    }
30}
31
32impl From<sqlx::Error> for EvaluationError {
33    fn from(err: sqlx::Error) -> Self {
34        Self::Repository(systemprompt_database::RepositoryError::from(err))
35    }
36}
37
38pub type Result<T> = std::result::Result<T, EvaluationError>;