Skip to main content

claw10_domain/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum DomainError {
5    #[error("not found: {0}")]
6    NotFound(String),
7
8    #[error("validation error: {0}")]
9    Validation(String),
10
11    #[error("policy denied: {0}")]
12    PolicyDenied(String),
13
14    #[error("budget exhausted: {0}")]
15    BudgetExhausted(String),
16
17    #[error("spawn depth exceeded: max {max}, current {current}")]
18    SpawnDepthExceeded { max: u32, current: u32 },
19
20    #[error("duplicate objective: {0}")]
21    DuplicateObjective(String),
22
23    #[error("invalid state transition: from {from:?} to {to:?}")]
24    InvalidStateTransition { from: String, to: String },
25
26    #[error("approval required: {0}")]
27    ApprovalRequired(String),
28
29    #[error("orphan agent: {0}")]
30    Orphan(String),
31
32    #[error("conflict: {0}")]
33    Conflict(String),
34
35    #[error("unauthorized: {0}")]
36    Unauthorized(String),
37
38    #[error("domain error: {0}")]
39    Other(String),
40}
41
42pub type DomainResult<T> = Result<T, DomainError>;