core/errors: add NotFound error

pull/1/head
Manos Pitsidianakis 2022-05-15 09:45:41 +03:00
parent 2190a44739
commit c5fb32a5ca
2 changed files with 13 additions and 5 deletions

View File

@ -18,6 +18,7 @@
*/
use super::*;
use crate::ErrorKind::*;
use melib::Envelope;
use models::changesets::*;
use rusqlite::Connection as DbConnection;
@ -243,10 +244,12 @@ impl Database {
}
pub fn remove_list_owner(&self, list_pk: i64, owner_pk: i64) -> Result<()> {
self.connection.execute(
"DELETE FROM list_owners WHERE list_pk = ? AND pk = ?;",
rusqlite::params![&list_pk, &owner_pk],
)?;
self.connection
.execute(
"DELETE FROM list_owners WHERE list_pk = ? AND pk = ?;",
rusqlite::params![&list_pk, &owner_pk],
)
.chain_err(|| NotFound("List owner"))?;
Ok(())
}
@ -648,7 +651,7 @@ impl Database {
/* FIXME - Notify submitter */
trace!("PostAction::Reject {{ reason: {} }}", reason);
//futures::executor::block_on(conn.mail_transaction(&post.bytes, b)).unwrap();
return Err(crate::ErrorKind::PostRejected(reason).into());
return Err(PostRejected(reason).into());
}
PostAction::Defer { reason } => {
trace!("PostAction::Defer {{ reason: {} }}", reason);

View File

@ -24,6 +24,11 @@ error_chain! {
description("Post rejected")
display("Your post has been rejected: {}", reason)
}
NotFound(model: &'static str) {
description("Not found")
display("This {} is not present in the database.", model)
}
}
foreign_links {
Sql(rusqlite::Error);