From 5dc001771e24adee7d8461d5a9f801ff8c1ef45d Mon Sep 17 00:00:00 2001 From: pcarles Date: Sun, 12 Nov 2023 02:38:44 +0100 Subject: [PATCH] fix: add comments --- src/services/category.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/category.rs b/src/services/category.rs index ca6bd933..ec3e5ca2 100644 --- a/src/services/category.rs +++ b/src/services/category.rs @@ -48,9 +48,10 @@ impl Service { // Try to get the category by name to check if it already exists match self.category_repository.get_by_name(trimmed_name).await { - // Return ServiceError::CategoryAlreadyExists when the category already exists + // Return ServiceError::CategoryAlreadyExists if the category exists Ok(_) => Err(ServiceError::CategoryAlreadyExists), Err(e) => match e { + // Otherwise try to create it DatabaseError::CategoryNotFound => match self.category_repository.add(trimmed_name).await { Ok(id) => Ok(id), Err(_) => Err(ServiceError::DatabaseError),