diff options
| author | Jokler <jokler.contact@gmail.com> | 2018-02-24 15:06:43 +0100 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2018-02-24 15:06:43 +0100 |
| commit | 5e309d4d58735e2ccc34542564265ace3cf1856e (patch) | |
| tree | c7b4ac8efe12a485cbf8d59d89fa3edf7a6db7e9 /src/plugins/factoids/database.rs | |
| parent | 5278972ee7e980cb6cace8db71d1e1ed8cd07c11 (diff) | |
| download | frippy-5e309d4d58735e2ccc34542564265ace3cf1856e.tar.gz frippy-5e309d4d58735e2ccc34542564265ace3cf1856e.zip | |
Log all database errors
Diffstat (limited to 'src/plugins/factoids/database.rs')
| -rw-r--r-- | src/plugins/factoids/database.rs | 17 |
1 files changed, 13 insertions, 4 deletions
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<Factoid> { - 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") + }, } } } |
