Skip to main content

mega_security_rs/
errors.rs

1use thiserror::Error;
2
3#[derive(Error, Debug, PartialEq)]
4pub enum ServerError {
5    #[error("client with id `{0}` is not registered")]
6    ClientNotFound(String),
7    #[error("autentication of user with id `{0}` failed")]
8    AutenticationFailed(String),
9    #[error("client with id `{0}` already exists")]
10    ClientAlreadyRegistred(String),
11    #[error("session id does not exist")]
12    SessionIdNotFound,
13}
14
15#[derive(Error, Debug)]
16pub enum ClientError {
17    #[error("could not decrypt keys")]
18    FailureToDecrypt,
19    #[error("could not decrypt data")]
20    FailureToDecryptData,
21    #[error("could not encrypt data")]
22    FailureToEncryptData,
23    
24    #[error("could not decode RSA key")]
25    RsaKeyDecodeFailed,
26    #[error("could not encode RSA key")]
27    RsaKeyEncodeFailed,
28    #[error("could not generate RSA key")]
29    RsaKeyGenerationFailed,
30
31    #[error("required key '{0}' are not present")]
32    KeyNotPresent(String),
33}