Skip to content

Commit

Permalink
fix: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarles committed Nov 12, 2023
1 parent 5f96cce commit 5dc0017
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/services/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 5dc0017

Please sign in to comment.