Skip to main content

atm_core/
error.rs

1//! Domain-specific error types following panic-free policy.
2
3use crate::SessionId;
4use thiserror::Error;
5
6/// Errors that can occur in domain operations.
7#[derive(Error, Debug, Clone)]
8pub enum DomainError {
9    /// Session not found in registry
10    #[error("Session not found: {session_id}")]
11    SessionNotFound { session_id: SessionId },
12
13    /// Session already exists
14    #[error("Session already exists: {session_id}")]
15    SessionAlreadyExists { session_id: SessionId },
16
17    /// Invalid field value
18    #[error("Invalid {field}: {value} (expected {expected})")]
19    InvalidFieldValue {
20        field: String,
21        value: String,
22        expected: String,
23    },
24
25    /// Parse error for incoming data
26    #[error("Failed to parse {field}: {reason}")]
27    ParseError { field: String, reason: String },
28}
29
30/// Result type for domain operations.
31pub type DomainResult<T> = Result<T, DomainError>;