From bd2a0bb8fd47f5d6c6e65308f1ccf6b039ccd3aa Mon Sep 17 00:00:00 2001 From: Justin Walters Date: Fri, 21 Aug 2020 20:30:08 -0700 Subject: [PATCH] fix db error messages (#353) Make the error messages for failed Database operations specific to their operation. --- todo/src/db.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/todo/src/db.rs b/todo/src/db.rs index 2bba1446..e129d8c3 100644 --- a/todo/src/db.rs +++ b/todo/src/db.rs @@ -18,7 +18,7 @@ fn get_conn(pool: &PgPool) -> Result { } pub fn get_all_tasks(pool: &PgPool) -> Result, &'static str> { - Task::all(get_conn(pool)?.deref()).map_err(|_| "Error inserting task") + Task::all(get_conn(pool)?.deref()).map_err(|_| "Error retrieving tasks") } pub fn create_task(todo: String, pool: &PgPool) -> Result<(), &'static str> { @@ -31,11 +31,11 @@ pub fn create_task(todo: String, pool: &PgPool) -> Result<(), &'static str> { pub fn toggle_task(id: i32, pool: &PgPool) -> Result<(), &'static str> { Task::toggle_with_id(id, get_conn(pool)?.deref()) .map(|_| ()) - .map_err(|_| "Error inserting task") + .map_err(|_| "Error toggling task completion") } pub fn delete_task(id: i32, pool: &PgPool) -> Result<(), &'static str> { Task::delete_with_id(id, get_conn(pool)?.deref()) .map(|_| ()) - .map_err(|_| "Error inserting task") + .map_err(|_| "Error deleting task") }