From 1cb49179d26cbd26673ac542b8e50fbabee1461f Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Fri, 15 Dec 2023 15:37:28 +0100 Subject: [PATCH] handle http error when pushing/pulling project --- packages/tauri/src/git/error.rs | 3 +++ packages/tauri/src/project_repository/repository.rs | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/tauri/src/git/error.rs b/packages/tauri/src/git/error.rs index 8b72372f7..a6cb5173b 100644 --- a/packages/tauri/src/git/error.rs +++ b/packages/tauri/src/git/error.rs @@ -16,6 +16,8 @@ pub enum Error { Network(git2::Error), #[error("hook error: {0}")] Hooks(#[from] git2_hooks::HooksError), + #[error("http error: {0}")] + Http(git2::Error), #[error(transparent)] Other(git2::Error), } @@ -27,6 +29,7 @@ impl From for Error { git2::ErrorCode::GenericError | git2::ErrorCode::Auth => Error::Auth(err), _ => Error::Other(err), }, + git2::ErrorClass::Http => Error::Http(err), git2::ErrorClass::Net => Error::Network(err), _ => match err.code() { git2::ErrorCode::NotFound => Error::NotFound(err), diff --git a/packages/tauri/src/project_repository/repository.rs b/packages/tauri/src/project_repository/repository.rs index 9f7a8cbfb..028f603f1 100644 --- a/packages/tauri/src/project_repository/repository.rs +++ b/packages/tauri/src/project_repository/repository.rs @@ -370,12 +370,12 @@ impl Repository { ); return Ok(()); } - Err(git::Error::Auth(error)) => { - tracing::warn!(project_id = %self.project.id, ?error, "git push failed",); + Err(git::Error::Auth(error) | git::Error::Http(error)) => { + tracing::warn!(project_id = %self.project.id, ?error, "git push failed"); continue; } Err(git::Error::Network(error)) => { - tracing::warn!(project_id = %self.project.id, ?error, "git push failed",); + tracing::warn!(project_id = %self.project.id, ?error, "git push failed"); return Err(RemoteError::Network); } Err(error) => return Err(RemoteError::Other(error.into())), @@ -407,7 +407,7 @@ impl Repository { tracing::info!(project_id = %self.project.id, %refspec, "git fetched"); return Ok(()); } - Err(git::Error::Auth(error)) => { + Err(git::Error::Auth(error) | git::Error::Http(error)) => { tracing::warn!(project_id = %self.project.id, ?error, "fetch failed"); continue; }