agentic_contract/
error.rs1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum ContractError {
8 #[error("Contract entity not found: {0}")]
10 NotFound(String),
11
12 #[error("Policy violation: {0}")]
14 PolicyViolation(String),
15
16 #[error("Risk limit exceeded: {limit} (current: {current}, max: {max})")]
18 RiskLimitExceeded {
19 limit: String,
21 current: f64,
23 max: f64,
25 },
26
27 #[error("Approval required: {0}")]
29 ApprovalRequired(String),
30
31 #[error("Approval denied: {0}")]
33 ApprovalDenied(String),
34
35 #[error("Condition not met: {0}")]
37 ConditionNotMet(String),
38
39 #[error("Obligation unfulfilled: {0}")]
41 ObligationUnfulfilled(String),
42
43 #[error("Contract expired: {0}")]
45 ContractExpired(String),
46
47 #[error("Invalid contract: {0}")]
49 InvalidContract(String),
50
51 #[error("File format error: {0}")]
53 FileFormat(String),
54
55 #[error("IO error: {0}")]
57 Io(#[from] std::io::Error),
58
59 #[error("Serialization error: {0}")]
61 Serialization(#[from] serde_json::Error),
62}
63
64pub type ContractResult<T> = Result<T, ContractError>;