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