1use thiserror::Error as ThisError;
2use argon2_rs::error::Argon2Error;
3
4#[derive(ThisError, Debug)]
5pub enum Error {
6 #[error("Hash Length cannot be less than 32 bytes")]
7 HashLength,
8
9 #[error("Header not found, data corrupted?")]
10 InvalidFileFormat,
11
12 #[error("Could not parse EncryptedInfo length")]
13 EncryptedInfo,
14
15 #[error("Invalid Credentials {0}")]
16 InvalidCredentials(String),
17
18 #[error("EncrytedInfo Encoding Failed {0}")]
19 EncodingFailed(String),
20
21 #[error("Encryption Failed {0}")]
22 EncryptionFailed(String),
23
24 #[error("EncryptedInfo Decoding Failed {0}")]
25 DecodingFailed(String),
26
27 #[error("Decryption Failed {0}")]
28 DecryptionFailed(String),
29
30 #[error("Failed to read file {0}")]
31 FileReadFailed(String),
32
33 #[error("Argon2 error: {0}")]
34 Argon2(#[from] Argon2Error),
35
36 #[error("{0}")]
37 Credentials(#[from] CredentialsError),
38
39 #[error("{0}")]
40 Custom(String),
41}
42
43
44#[derive(ThisError, Debug)]
45pub enum CredentialsError {
46 #[error("Username is empty")]
47 UsernameEmpty,
48
49 #[error("Password is empty")]
50 PasswordEmpty,
51
52 #[error("Confirm password is empty")]
53 ConfirmPasswordEmpty,
54
55 #[error("Passwords do not match")]
56 PasswordsDoNotMatch,
57
58 #[error("{0}")]
59 Custom(String),
60}