lab_resource_manager/domain/aggregates/identity_link/
errors.rs

1use super::value_objects::ExternalSystem;
2use std::fmt;
3
4/// IdentityLink集約のドメインエラー型
5#[derive(Debug, Clone, PartialEq)]
6pub enum IdentityLinkError {
7    /// 指定された外部システムの識別情報が既に存在する
8    IdentityAlreadyExists { system: ExternalSystem },
9    /// 指定された外部システムの識別情報が見つからない
10    IdentityNotFound { system: ExternalSystem },
11}
12
13impl fmt::Display for IdentityLinkError {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        match self {
16            Self::IdentityAlreadyExists { system } => {
17                write!(
18                    f,
19                    "外部システム {} の識別情報は既に登録されています",
20                    system.as_str()
21                )
22            }
23            Self::IdentityNotFound { system } => {
24                write!(
25                    f,
26                    "外部システム {} の識別情報が見つかりません",
27                    system.as_str()
28                )
29            }
30        }
31    }
32}
33
34impl std::error::Error for IdentityLinkError {}
35
36impl crate::domain::errors::DomainError for IdentityLinkError {}