From 4a8e69f7f3069f8d059d0f88fba72e03712fd591 Mon Sep 17 00:00:00 2001 From: Jokler Date: Sun, 24 Dec 2017 15:22:29 +0100 Subject: Log database errors and send a notice if no factoid was deleted --- src/plugins/factoids/database.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/plugins/factoids') diff --git a/src/plugins/factoids/database.rs b/src/plugins/factoids/database.rs index 1af586e..cb6f422 100644 --- a/src/plugins/factoids/database.rs +++ b/src/plugins/factoids/database.rs @@ -106,8 +106,8 @@ impl Database for MysqlConnection { .execute(self) { Ok(_) => DbResponse::Success, Err(e) => { - debug!("DB Insertion Error: {:?}", e); - DbResponse::Failed("Database error - possible duplicate") + error!("DB Insertion Error: {:?}", e); + DbResponse::Failed("Failed to add factoid") } } } @@ -123,9 +123,15 @@ impl Database for MysqlConnection { .filter(columns::name.eq(name)) .filter(columns::idx.eq(idx))) .execute(self) { - Ok(_) => DbResponse::Success, + Ok(v) => { + if v > 0 { + DbResponse::Success + } else { + DbResponse::Failed("Could not find any factoid with that name") + } + } Err(e) => { - debug!("DB Deletion Error: {:?}", e); + error!("DB Deletion Error: {:?}", e); DbResponse::Failed("Failed to delete factoid") } } -- cgit v1.2.3-70-g09d2