1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum OfficeError {
8 #[error("cognition error: {0}")]
10 Brain(String),
11 #[error("policy gate error: {0}")]
13 Gate(String),
14 #[error("policy violation: {0}")]
16 PolicyViolation(String),
17 #[error("tool execution error: {0}")]
19 Tool(String),
20 #[error("io error: {0}")]
22 Io(String),
23 #[error("config error: {0}")]
25 Config(String),
26 #[error("context overflow: {0}")]
28 ContextOverflow(String),
29 #[error("quota exceeded: {0}")]
31 QuotaExceeded(String),
32 #[error("ledger error: {0}")]
34 Ledger(String),
35 #[error("provider error: {0}")]
37 Provider(String),
38 #[error("shutdown requested")]
40 Shutdown,
41}
42
43impl From<std::io::Error> for OfficeError {
44 fn from(e: std::io::Error) -> Self {
45 Self::Io(e.to_string())
46 }
47}
48
49impl From<tdln_brain::BrainError> for OfficeError {
50 fn from(e: tdln_brain::BrainError) -> Self {
51 match e {
52 tdln_brain::BrainError::ContextOverflow => {
53 Self::ContextOverflow("brain context overflow".into())
54 }
55 tdln_brain::BrainError::Provider(msg) => Self::Provider(msg),
56 other => Self::Brain(other.to_string()),
57 }
58 }
59}
60
61impl From<ubl_mcp::McpError> for OfficeError {
62 fn from(e: ubl_mcp::McpError) -> Self {
63 match e {
64 ubl_mcp::McpError::PolicyViolation(msg) => Self::PolicyViolation(msg),
65 other => Self::Tool(other.to_string()),
66 }
67 }
68}