Skip to main content

easy_archive/
error.rs

1/// Error types for archive operations
2use thiserror::Error;
3
4/// Result type alias for archive operations
5pub type Result<T> = std::result::Result<T, ArchiveError>;
6
7/// Errors that can occur during archive operations
8#[derive(Error, Debug)]
9pub enum ArchiveError {
10    /// I/O error occurred during archive operation
11    #[error("I/O error: {0}")]
12    Io(#[from] std::io::Error),
13
14    /// Failed to decode an archive
15    #[error("Failed to decode {format} archive: {reason}")]
16    DecodeFailed {
17        /// The archive format that failed to decode
18        format: String,
19        /// The reason for the failure
20        reason: String,
21    },
22
23    /// Failed to encode an archive
24    #[error("Failed to encode {format} archive: {reason}")]
25    EncodeFailed {
26        /// The archive format that failed to encode
27        format: String,
28        /// The reason for the failure
29        reason: String,
30    },
31
32    /// Duplicate file paths detected in the archive
33    #[error("Duplicate file paths detected: {}", .paths.join(", "))]
34    DuplicateFiles {
35        /// List of duplicate file paths
36        paths: Vec<String>,
37    },
38
39    /// The archive format is not supported or not enabled
40    #[error("Unsupported format: {0}")]
41    UnsupportedFormat(String),
42
43    /// The archive structure is invalid
44    #[error("Invalid archive structure: {0}")]
45    InvalidArchive(String),
46
47    /// Compression operation failed
48    #[error("Compression error: {0}")]
49    CompressionError(String),
50
51    /// Decompression operation failed
52    #[error("Decompression error: {0}")]
53    DecompressionError(String),
54}