0e162fdfeat: bootstrap_owner and login use cases1mo | 1 | use crate::domain::{DomainError, repository::RepositoryError}; |
| 2 | |
b7a57dbfeat: a repository can be taken away as a file16h | 3 | use super::port::{ |
| 4 | GitArchiveError, GitProtocolError, GitQueryError, GitStorageError, PasswordError, |
| 5 | }; |
0e162fdfeat: bootstrap_owner and login use cases1mo | 6 | |
| 7 | |
| 8 | |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 9 | |
| 10 | |
| 11 | |
| 12 | |
0e162fdfeat: bootstrap_owner and login use cases1mo | 13 | #[derive(Debug)] |
| 14 | pub enum Error { |
| 15 | |
| 16 | Domain(DomainError), |
| 17 | |
| 18 | Repository(RepositoryError), |
| 19 | |
| 20 | Password(PasswordError), |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 21 | |
| 22 | GitStorage(GitStorageError), |
47db238feat: serve the git protocol through http-backend, behind a port8d | 23 | |
| 24 | GitProtocol(GitProtocolError), |
dce0bf3feat: browse a repository's files and history8d | 25 | |
| 26 | GitQuery(GitQueryError), |
b7a57dbfeat: a repository can be taken away as a file16h | 27 | |
| 28 | GitArchive(GitArchiveError), |
0e162fdfeat: bootstrap_owner and login use cases1mo | 29 | } |
| 30 | |
| 31 | impl From<DomainError> for Error { |
| 32 | fn from(error: DomainError) -> Self { |
| 33 | Self::Domain(error) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | impl From<RepositoryError> for Error { |
| 38 | fn from(error: RepositoryError) -> Self { |
| 39 | Self::Repository(error) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | impl From<PasswordError> for Error { |
| 44 | fn from(error: PasswordError) -> Self { |
| 45 | Self::Password(error) |
| 46 | } |
| 47 | } |
| 48 | |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 49 | impl From<GitStorageError> for Error { |
| 50 | fn from(error: GitStorageError) -> Self { |
| 51 | Self::GitStorage(error) |
| 52 | } |
| 53 | } |
| 54 | |
47db238feat: serve the git protocol through http-backend, behind a port8d | 55 | impl From<GitProtocolError> for Error { |
| 56 | fn from(error: GitProtocolError) -> Self { |
| 57 | Self::GitProtocol(error) |
| 58 | } |
| 59 | } |
| 60 | |
dce0bf3feat: browse a repository's files and history8d | 61 | impl From<GitQueryError> for Error { |
| 62 | fn from(error: GitQueryError) -> Self { |
| 63 | Self::GitQuery(error) |
| 64 | } |
| 65 | } |
| 66 | |
b7a57dbfeat: a repository can be taken away as a file16h | 67 | impl From<GitArchiveError> for Error { |
| 68 | fn from(error: GitArchiveError) -> Self { |
| 69 | Self::GitArchive(error) |
| 70 | } |
| 71 | } |
| 72 | |
0e162fdfeat: bootstrap_owner and login use cases1mo | 73 | impl std::fmt::Display for Error { |
| 74 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 75 | match self { |
| 76 | Self::Domain(error) => write!(f, "{error}"), |
| 77 | Self::Repository(error) => write!(f, "{error}"), |
| 78 | Self::Password(error) => write!(f, "{error}"), |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 79 | Self::GitStorage(error) => write!(f, "{error}"), |
47db238feat: serve the git protocol through http-backend, behind a port8d | 80 | Self::GitProtocol(error) => write!(f, "{error}"), |
dce0bf3feat: browse a repository's files and history8d | 81 | Self::GitQuery(error) => write!(f, "{error}"), |
b7a57dbfeat: a repository can be taken away as a file16h | 82 | Self::GitArchive(error) => write!(f, "{error}"), |
0e162fdfeat: bootstrap_owner and login use cases1mo | 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | impl std::error::Error for Error { |
| 88 | fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { |
| 89 | match self { |
| 90 | Self::Domain(error) => Some(error), |
| 91 | Self::Repository(error) => Some(error), |
| 92 | Self::Password(error) => Some(error), |
02eb2e4feat: GitStorage port and DiskGitStorage24d | 93 | Self::GitStorage(error) => Some(error), |
47db238feat: serve the git protocol through http-backend, behind a port8d | 94 | Self::GitProtocol(error) => Some(error), |
dce0bf3feat: browse a repository's files and history8d | 95 | Self::GitQuery(error) => Some(error), |
b7a57dbfeat: a repository can be taken away as a file16h | 96 | Self::GitArchive(error) => Some(error), |
0e162fdfeat: bootstrap_owner and login use cases1mo | 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | pub type Result<T> = std::result::Result<T, Error>; |