0e162fdfeat: bootstrap_owner and login use cases1mo | 1 | use crate::domain::{DomainError, repository::RepositoryError}; |
| 2 | |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 3 | use super::port::{GitStorageError, PasswordError}; |
0e162fdfeat: bootstrap_owner and login use cases1mo | 4 | |
| 5 | |
| 6 | |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 7 | |
| 8 | |
| 9 | |
| 10 | |
0e162fdfeat: bootstrap_owner and login use cases1mo | 11 | #[derive(Debug)] |
| 12 | pub enum Error { |
| 13 | |
| 14 | Domain(DomainError), |
| 15 | |
| 16 | Repository(RepositoryError), |
| 17 | |
| 18 | Password(PasswordError), |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 19 | |
| 20 | GitStorage(GitStorageError), |
0e162fdfeat: bootstrap_owner and login use cases1mo | 21 | } |
| 22 | |
| 23 | impl From<DomainError> for Error { |
| 24 | fn from(error: DomainError) -> Self { |
| 25 | Self::Domain(error) |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | impl From<RepositoryError> for Error { |
| 30 | fn from(error: RepositoryError) -> Self { |
| 31 | Self::Repository(error) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | impl From<PasswordError> for Error { |
| 36 | fn from(error: PasswordError) -> Self { |
| 37 | Self::Password(error) |
| 38 | } |
| 39 | } |
| 40 | |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 41 | impl From<GitStorageError> for Error { |
| 42 | fn from(error: GitStorageError) -> Self { |
| 43 | Self::GitStorage(error) |
| 44 | } |
| 45 | } |
| 46 | |
0e162fdfeat: bootstrap_owner and login use cases1mo | 47 | impl std::fmt::Display for Error { |
| 48 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 49 | match self { |
| 50 | Self::Domain(error) => write!(f, "{error}"), |
| 51 | Self::Repository(error) => write!(f, "{error}"), |
| 52 | Self::Password(error) => write!(f, "{error}"), |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 53 | Self::GitStorage(error) => write!(f, "{error}"), |
0e162fdfeat: bootstrap_owner and login use cases1mo | 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | impl std::error::Error for Error { |
| 59 | fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { |
| 60 | match self { |
| 61 | Self::Domain(error) => Some(error), |
| 62 | Self::Repository(error) => Some(error), |
| 63 | Self::Password(error) => Some(error), |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 64 | Self::GitStorage(error) => Some(error), |
0e162fdfeat: bootstrap_owner and login use cases1mo | 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | pub type Result<T> = std::result::Result<T, Error>; |