You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
git-view/src/error.rs

38 lines
786 B
Rust

#[derive(Debug, PartialEq)]
pub enum ErrorType {
CommandFailed,
CommandError,
MissingGitRepository,
MissingGitRemote,
InvalidGitUrl,
InvalidUtf8,
IOError,
}
#[derive(Debug, PartialEq)]
pub struct AppError {
pub error_type: ErrorType,
pub error_str: String,
}
impl From<std::io::Error> for AppError {
fn from(error: std::io::Error) -> Self {
AppError::new(ErrorType::IOError, error.to_string())
}
}
impl From<std::str::Utf8Error> for AppError {
fn from(error: std::str::Utf8Error) -> Self {
AppError::new(ErrorType::InvalidUtf8, error.to_string())
}
}
impl AppError {
pub fn new(error_type: ErrorType, error_str: String) -> Self {
Self {
error_type,
error_str,
}
}
}