0e162fdfeat: bootstrap_owner and login use cases1mo | 1 | use crate::domain::{DomainError, repository::RepositoryError}; |
| 2 | |
47db238feat: serve the git protocol through http-backend, behind a port8d | 3 | use super::port::{GitProtocolError, 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), |
47db238feat: serve the git protocol through http-backend, behind a port8d | 21 | |
| 22 | GitProtocol(GitProtocolError), |
0e162fdfeat: bootstrap_owner and login use cases1mo | 23 | } |
| 24 | |
| 25 | impl From<DomainError> for Error { |
| 26 | fn from(error: DomainError) -> Self { |
| 27 | Self::Domain(error) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | impl From<RepositoryError> for Error { |
| 32 | fn from(error: RepositoryError) -> Self { |
| 33 | Self::Repository(error) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | impl From<PasswordError> for Error { |
| 38 | fn from(error: PasswordError) -> Self { |
| 39 | Self::Password(error) |
| 40 | } |
| 41 | } |
| 42 | |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 43 | impl From<GitStorageError> for Error { |
| 44 | fn from(error: GitStorageError) -> Self { |
| 45 | Self::GitStorage(error) |
| 46 | } |
| 47 | } |
| 48 | |
47db238feat: serve the git protocol through http-backend, behind a port8d | 49 | impl From<GitProtocolError> for Error { |
| 50 | fn from(error: GitProtocolError) -> Self { |
| 51 | Self::GitProtocol(error) |
| 52 | } |
| 53 | } |
| 54 | |
0e162fdfeat: bootstrap_owner and login use cases1mo | 55 | impl std::fmt::Display for Error { |
| 56 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 57 | match self { |
| 58 | Self::Domain(error) => write!(f, "{error}"), |
| 59 | Self::Repository(error) => write!(f, "{error}"), |
| 60 | Self::Password(error) => write!(f, "{error}"), |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 61 | Self::GitStorage(error) => write!(f, "{error}"), |
47db238feat: serve the git protocol through http-backend, behind a port8d | 62 | Self::GitProtocol(error) => write!(f, "{error}"), |
0e162fdfeat: bootstrap_owner and login use cases1mo | 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | impl std::error::Error for Error { |
| 68 | fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { |
| 69 | match self { |
| 70 | Self::Domain(error) => Some(error), |
| 71 | Self::Repository(error) => Some(error), |
| 72 | Self::Password(error) => Some(error), |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 73 | Self::GitStorage(error) => Some(error), |
47db238feat: serve the git protocol through http-backend, behind a port8d | 74 | Self::GitProtocol(error) => Some(error), |
0e162fdfeat: bootstrap_owner and login use cases1mo | 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | pub type Result<T> = std::result::Result<T, Error>; |