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:
parent
4b445a6a96
commit
98f0563952
4 changed files with 17 additions and 19 deletions
|
@ -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(_) => (),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue