nx_archive/
error.rs

1use cipher::InvalidLength;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum Error {
6    #[error("IO error: {0}")]
7    Io(#[from] std::io::Error),
8    #[error("Invalid argument: {0}")]
9    InvalidArgument(String),
10    #[error("Invalid data: {0}")]
11    InvalidData(String),
12    #[error("Unable to parse binary data: {0}")]
13    BinaryParser(#[from] binrw::Error),
14    #[error("Unable to parse string: {0}")]
15    StringParser(#[from] core::str::Utf8Error),
16    #[error("Invalid state: {0}")]
17    InvalidState(String),
18    #[error("Invalid format: {0}")]
19    InvalidFormat(String),
20    #[error("Invalid operation: {0}")]
21    InvalidOperation(String),
22    #[error("Not found: {0}")]
23    NotFound(String),
24    #[error("Not supported: {0}")]
25    NotSupported(String),
26    #[error("Permission denied: {0}")]
27    PermissionDenied(String),
28    #[error("Timeout: {0}")]
29    Timeout(String),
30    #[error("Other error: {0}")]
31    Other(String),
32    #[error("Encryption error: {0}")]
33    CryptoError(String),
34    #[error("Key Lookup error: {0}")]
35    KeyLookupError(String),
36    #[error("Title key error: {0}")]
37    TitleKeyError(#[from] crate::formats::title_keyset::KeyError),
38}
39
40impl From<InvalidLength> for Error {
41    fn from(_: InvalidLength) -> Self {
42        Error::CryptoError("Invalid key length".to_string())
43    }
44}