mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-03 03:33:16 +03:00
categorize git network error
This commit is contained in:
parent
372f60189b
commit
af9b9c465b
@ -3,42 +3,47 @@ use crate::keys;
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("not found: {0}")]
|
||||
NotFound(Box<dyn std::error::Error + Send + Sync>),
|
||||
NotFound(git2::Error),
|
||||
#[error("authentication failed")]
|
||||
AuthenticationFailed(Box<dyn std::error::Error + Send + Sync>),
|
||||
Auth(git2::Error),
|
||||
#[error("sign error: {0}")]
|
||||
SignError(Box<dyn std::error::Error + Send + Sync>),
|
||||
Signing(keys::SignError),
|
||||
#[error("remote url error: {0}")]
|
||||
RemoteUrlError(Box<dyn std::error::Error + Send + Sync>),
|
||||
Url(super::url::ParseError),
|
||||
#[error("io error: {0}")]
|
||||
IoError(#[from] std::io::Error),
|
||||
Io(#[from] std::io::Error),
|
||||
#[error("network error: {0}")]
|
||||
Network(git2::Error),
|
||||
#[error(transparent)]
|
||||
Other(Box<dyn std::error::Error + Send + Sync>),
|
||||
Other(git2::Error),
|
||||
}
|
||||
|
||||
impl From<git2::Error> for Error {
|
||||
fn from(err: git2::Error) -> Self {
|
||||
if err.class() == git2::ErrorClass::Ssh && err.code() == git2::ErrorCode::GenericError {
|
||||
Error::AuthenticationFailed(err.into())
|
||||
} else {
|
||||
match err.code() {
|
||||
git2::ErrorCode::NotFound => Error::NotFound(err.into()),
|
||||
git2::ErrorCode::Auth => Error::AuthenticationFailed(err.into()),
|
||||
_ => Error::Other(err.into()),
|
||||
}
|
||||
match err.class() {
|
||||
git2::ErrorClass::Ssh => match err.code() {
|
||||
git2::ErrorCode::GenericError => Error::Auth(err),
|
||||
_ => Error::Other(err),
|
||||
},
|
||||
git2::ErrorClass::Net => Error::Network(err),
|
||||
_ => match err.code() {
|
||||
git2::ErrorCode::NotFound => Error::NotFound(err),
|
||||
git2::ErrorCode::Auth => Error::Auth(err),
|
||||
_ => Error::Other(err),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<keys::SignError> for Error {
|
||||
fn from(err: keys::SignError) -> Self {
|
||||
Error::SignError(err.into())
|
||||
Error::Signing(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<super::url::ParseError> for Error {
|
||||
fn from(err: super::url::ParseError) -> Self {
|
||||
Error::RemoteUrlError(err.into())
|
||||
Error::Url(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ impl Repository {
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
Err(git::Error::AuthenticationFailed(error)) => {
|
||||
Err(git::Error::Auth(error)) => {
|
||||
tracing::warn!(project_id = %self.project.id, ?error, "git push failed",);
|
||||
continue;
|
||||
}
|
||||
@ -519,7 +519,7 @@ impl Repository {
|
||||
tracing::info!(project_id = %self.project.id, %refspec, "git fetched");
|
||||
return Ok(());
|
||||
}
|
||||
Err(git::Error::AuthenticationFailed(error)) => {
|
||||
Err(git::Error::Auth(error)) => {
|
||||
tracing::warn!(project_id = %self.project.id, ?error, "fetch failed");
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user