Skip to content

Commit

Permalink
fix error type
Browse files Browse the repository at this point in the history
  • Loading branch information
katayama8000 committed Feb 14, 2024
1 parent 7366950 commit 69dee5f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/domain/aggregate/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ impl Circle {
}

// メンバーをサークルに追加するメソッド
pub fn add_member(&mut self, member: Member) -> Result<(), String> {
pub fn add_member(&mut self, member: Member) -> Result<(), Error> {
// 満員の場合はサークルに入れない
if self.is_full() {
return Err("Circle member is full".to_string());
return Err(Error::msg("Circle member is full"));
}

// 4年生はサークルに入れない
if member.grade == Grade::Fourth {
return Err("4th grade can't join circle".to_string());
return Err(Error::msg("4th grade can't join circle"));
}

self.members.push(member);
Ok(())
}

// メンバーをサークルから削除するメソッド
pub fn remove_member(&mut self, member: &Member) -> Result<(), String> {
pub fn remove_member(&mut self, member: &Member) -> Result<(), Error> {
// オーナーは削除できない
if self.owner.id == member.id {
return Err("Owner can't be removed".to_string());
return Err(Error::msg("Owner can't be removed"));
}
self.members.retain(|m| m.id != member.id);
Ok(())
Expand Down

0 comments on commit 69dee5f

Please sign in to comment.