From 5e309d4d58735e2ccc34542564265ace3cf1856e Mon Sep 17 00:00:00 2001 From: Jokler Date: Sat, 24 Feb 2018 15:06:43 +0100 Subject: Log all database errors --- src/plugins/factoids/database.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/plugins/factoids/database.rs') diff --git a/src/plugins/factoids/database.rs b/src/plugins/factoids/database.rs index b612d6f..53efe6a 100644 --- a/src/plugins/factoids/database.rs +++ b/src/plugins/factoids/database.rs @@ -106,14 +106,20 @@ impl Database for MysqlConnection { .execute(self) { Ok(_) => DbResponse::Success, Err(e) => { - error!("DB Insertion Error: \"{}\"", e); + error!("DB Insertion Error: {}", e); DbResponse::Failed("Failed to add factoid") } } } fn get(&self, name: &str, idx: i32) -> Option { - factoids::table.find((name, idx)).first(self).ok() + match factoids::table.find((name, idx)).first(self) { + Ok(f) => Ok(f), + Err(e) => { + error!("DB Count Error: {}", e); + None + }, + } } fn delete(&mut self, name: &str, idx: i32) -> DbResponse { @@ -131,7 +137,7 @@ impl Database for MysqlConnection { } } Err(e) => { - error!("DB Deletion Error: \"{}\"", e); + error!("DB Deletion Error: {}", e); DbResponse::Failed("Failed to delete factoid") } } @@ -145,7 +151,10 @@ impl Database for MysqlConnection { match count { Ok(c) => Ok(c as i32), - Err(_) => Err("Database Error"), + Err(e) => { + error!("DB Count Error: {}", e); + Err("Database Error") + }, } } } -- cgit v1.2.3-70-g09d2