rusty_jar/
error.rs

1use snafu::Snafu;
2use std::path::PathBuf;
3
4/// Represents errors that can occur while working with JAR files.
5#[derive(Debug, Snafu)]
6#[snafu(visibility(pub))]
7pub enum JarError {
8    #[snafu(display("I/O error for path '{path}': {source}", path = path.display()))]
9    Io {
10        #[snafu(source)]
11        source: std::io::Error,
12        path: PathBuf,
13    },
14    #[snafu(display("Zip error: {source}"))]
15    Zip {
16        #[snafu(source)]
17        source: zip::result::ZipError,
18    },
19    #[snafu(display("Entry not found: {entry_name}"))]
20    EntryNotFound { entry_name: String },
21}
22
23/// Type alias for a Result type that uses JarError for error handling.
24pub type Result<T> = std::result::Result<T, JarError>;
25
26impl From<zip::result::ZipError> for JarError {
27    fn from(value: zip::result::ZipError) -> Self {
28        JarError::Zip { source: value }
29    }
30}