Skip to main content

attack/
error.rs

1//! Error types for ATT&CK operations
2//!
3//! This module provides comprehensive error handling for ATT&CK operations
4//! including loading, validation, and parsing.
5
6use thiserror::Error;
7
8/// Main error type for ATT&CK operations
9#[derive(Debug, Error)]
10pub enum AttackError {
11    /// I/O error when reading files
12    #[error("I/O error: {0}")]
13    IoError(#[from] std::io::Error),
14
15    /// JSON serialization/deserialization error
16    #[error("serialization error: {0}")]
17    SerializationError(#[from] serde_json::Error),
18
19    /// Network error when fetching remote data
20    #[error("network error: {0}")]
21    NetworkError(#[from] reqwest::Error),
22
23    /// Invalid ATT&CK ID format
24    #[error("invalid ATT&CK ID: {0}")]
25    InvalidId(String),
26
27    /// Missing required field
28    #[error("missing required field: {0}")]
29    MissingField(&'static str),
30
31    /// Object not found
32    #[error("object not found: {0}")]
33    NotFound(String),
34
35    /// Validation error
36    #[error("validation error: {0}")]
37    ValidationError(String),
38}
39
40/// Specialized Result type for ATT&CK operations
41pub type Result<T> = std::result::Result<T, AttackError>;