GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — clibrowser/cligit/src/error.rs at main · allthingssecurity/clibrowser Expand file tree/ Copy patherror.rsMore file actions 81 lines (66 loc) · 2.14 KB / Copy patherror.rsFile metadata and controls81 lines (66 loc) · 2.14 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 use thiserror::Error; #[derive(Error, Debug)] pub enum GitError { #[error("Not a git repository (or any parent up to mount point)")] NotARepo, #[error("Cannot operate on bare repository")] BareRepo, #[error("Reference not found: {0}")] RefNotFound(String), #[error("File not found: {0} (ref: {1})")] FileNotFound(String, String), #[error("Merge conflicts in {0} file(s)")] MergeConflict(usize), #[error("Working tree has uncommitted changes")] DirtyWorkTree, #[error("Authentication required for {0}")] AuthRequired(String), #[error("Remote error: {0}")] RemoteError(String), #[error("git2: {0}")] Git2(String), #[error("IO error: {0}")] Io(String), #[error("{0}")] Other(String), } impl GitError { pub fn exit_code(&self) -> i32 { match self { GitError::NotARepo | GitError::BareRepo => 1, GitError::RefNotFound(_) | GitError::FileNotFound(_, _) | GitError::MergeConflict(_) | GitError::DirtyWorkTree | GitError::Git2(_) | GitError::Other(_) => 2, GitError::Io(_) => 3, GitError::AuthRequired(_) | GitError::RemoteError(_) => 4, } } pub fn error_code(&self) -> &'static str { match self { GitError::NotARepo => "not_a_repo", GitError::BareRepo => "bare_repo", GitError::RefNotFound(_) => "ref_not_found", GitError::FileNotFound(_, _) => "file_not_found", GitError::MergeConflict(_) => "merge_conflict", GitError::DirtyWorkTree => "dirty_worktree", GitError::AuthRequired(_) => "auth_required", GitError::RemoteError(_) => "remote_error", GitError::Git2(_) => "git2_error", GitError::Io(_) => "io_error", GitError::Other(_) => "error", } } } impl From<git2::Error> for GitError { fn from(e: git2::Error) -> Self { GitError::Git2(e.message().to_string()) } } impl From<std::io::Error> for GitError { fn from(e: std::io::Error) -> Self { GitError::Io(e.to_string()) } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |