I have the following code for deleting a todo from my sqlite table:
pub fn delete_todo(id: String) -> Result(Int, sqlight.Error) {
let assert Ok(conn) = open_db_conn()
let sql = "DELETE FROM todos WHERE id = " <> id
wisp.log_info("Attempting to delete todo with ID: " <> id)
// use item <- result.try(sqlight.exec(sql, conn))
let item = sqlight.exec(sql, conn)
case item {
Ok(_item) -> {
wisp.log_info("Todo with ID " <> id <> " deleted successfully.")
Ok(1)
// Return 1 to indicate one row affected
}
Error(error) -> {
wisp.log_error(
"Error deleting todo with ID " <> id <> ": " <> error.message,
)
Error(error)
}
}
}
But I've noticed that if I pass an ID that doesn't exist it still prints out the log message Todo with ID 10000 deleted successfully. I know that sqlight.exec function returns a Nil or sqlight.Error just wondering why the error is not being called