0
0
Fork 0
mirror of https://git.verdigado.com/NB-Public/simple-wkd.git synced 2024-12-06 14:52:41 +01:00
simple-wkd/src/errors.rs
2023-04-13 22:00:33 +02:00

35 lines
992 B
Rust

use actix_web::http::StatusCode;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Error while parsing cert")]
ParseCert,
#[error("Error while parsing E-Mail")]
ParseMail,
#[error("Error while parsing stored data")]
ParseStored,
#[error("No E-Mail found in the certificate")]
MissingMail,
#[error("The E-Mail is malformed")]
MalformedMail,
#[error("Error while serializing data")]
SerializeData,
#[error("Error while deserializing data")]
DeserializeData,
#[error("File or directory does not exist")]
MissingPath,
#[error("The file is inaccessible")]
Inaccessible,
#[error("Error while adding a key to the wkd")]
AddingKey,
}
impl actix_web::ResponseError for Error {
fn status_code(&self) -> actix_web::http::StatusCode {
match self {
Self::MissingPath => StatusCode::from_u16(404).unwrap(),
_ => StatusCode::from_u16(500).unwrap(),
}
}
}