0
0
Fork 0
mirror of https://git.verdigado.com/NB-Public/simple-wkd.git synced 2024-12-06 14:52:41 +01:00

Improve error handling

This commit is contained in:
Delta1925 2023-04-13 23:32:12 +02:00
parent 4b445a6a96
commit 98f0563952
No known key found for this signature in database
GPG key ID: 1C21ACE44193CB25
4 changed files with 17 additions and 19 deletions

View file

@ -15,18 +15,18 @@ pub fn confirm_action(token: &str) -> Result<(), Error> {
Err(_) => return Err(Error::Inaccessible),
}
} else {
return Err(Error::MissingPath);
return Err(Error::MissingPending);
};
let key = match serde_json::from_str::<Pending>(&content) {
Ok(key) => key,
Err(_) => return Err(Error::ParseStored),
Err(_) => return Err(Error::DeserializeData),
};
match key.action() {
Action::Add => {
let cert = parse_pem(key.data())?;
let domain = match get_email_from_cert(&cert)?.split('@').last() {
Some(domain) => domain.to_string(),
None => return Err(Error::MalformedMail),
None => return Err(Error::ParseEmail),
};
match sequoia_net::wkd::insert(PATH, domain, VARIANT, &cert) {
Ok(_) => (),