forked from gitui-org/gitui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.rs
More file actions
40 lines (29 loc) · 895 Bytes
/
error.rs
File metadata and controls
40 lines (29 loc) · 895 Bytes
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
use std::{num::TryFromIntError, string::FromUtf8Error};
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("`{0}`")]
Generic(String),
#[error("git: no head found")]
NoHead,
#[error("git: remote url not found")]
UnknownRemote,
#[error("git: inconclusive remotes")]
NoDefaultRemoteFound,
#[error("git: work dir error")]
NoWorkDir,
#[error("io error:{0}")]
Io(#[from] std::io::Error),
#[error("git error:{0}")]
Git(#[from] git2::Error),
#[error("utf8 error:{0}")]
Utf8Error(#[from] FromUtf8Error),
#[error("TryFromInt error:{0}")]
IntError(#[from] TryFromIntError),
}
pub type Result<T> = std::result::Result<T, Error>;
impl<T> From<std::sync::PoisonError<T>> for Error {
fn from(error: std::sync::PoisonError<T>) -> Self {
Error::Generic(format!("poison error: {}", error))
}
}