aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2017-12-24 15:22:29 +0100
committerJokler <jokler.contact@gmail.com>2017-12-24 15:22:29 +0100
commit4a8e69f7f3069f8d059d0f88fba72e03712fd591 (patch)
tree813e9c70880e665f9e48089b04c7106491de5181
parentb98d1ce014eb6b502601547d46fc522ed6a4b416 (diff)
downloadfrippy-4a8e69f7f3069f8d059d0f88fba72e03712fd591.tar.gz
frippy-4a8e69f7f3069f8d059d0f88fba72e03712fd591.zip
Log database errors and send a notice if no factoid was deleted
-rw-r--r--src/plugins/factoids/database.rs14
1 files changed, 10 insertions, 4 deletions
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")
}
}