Remove git-specific error cases from origin errors
This commit is contained in:
parent
1a6f804289
commit
4075b3e2cd
@ -46,15 +46,12 @@ pub enum SyncWithSettingsError {
|
|||||||
#[error("domain's settings cannot be modified")]
|
#[error("domain's settings cannot be modified")]
|
||||||
NotModifiable,
|
NotModifiable,
|
||||||
|
|
||||||
#[error("invalid url")]
|
#[error("invalid descr")]
|
||||||
InvalidURL,
|
InvalidDescr(String),
|
||||||
|
|
||||||
#[error("unavailable due to server-side issue")]
|
#[error("unavailable due to upstream issue")]
|
||||||
Unavailable,
|
Unavailable,
|
||||||
|
|
||||||
#[error("invalid branch name")]
|
|
||||||
InvalidBranchName,
|
|
||||||
|
|
||||||
#[error("already in progress")]
|
#[error("already in progress")]
|
||||||
AlreadyInProgress,
|
AlreadyInProgress,
|
||||||
|
|
||||||
@ -71,9 +68,8 @@ pub enum SyncWithSettingsError {
|
|||||||
impl From<origin::SyncError> for SyncWithSettingsError {
|
impl From<origin::SyncError> for SyncWithSettingsError {
|
||||||
fn from(e: origin::SyncError) -> SyncWithSettingsError {
|
fn from(e: origin::SyncError) -> SyncWithSettingsError {
|
||||||
match e {
|
match e {
|
||||||
origin::SyncError::InvalidURL => SyncWithSettingsError::InvalidURL,
|
origin::SyncError::InvalidDescr(msg) => SyncWithSettingsError::InvalidDescr(msg),
|
||||||
origin::SyncError::Unavailable => SyncWithSettingsError::Unavailable,
|
origin::SyncError::Unavailable => SyncWithSettingsError::Unavailable,
|
||||||
origin::SyncError::InvalidBranchName => SyncWithSettingsError::InvalidBranchName,
|
|
||||||
origin::SyncError::AlreadyInProgress => SyncWithSettingsError::AlreadyInProgress,
|
origin::SyncError::AlreadyInProgress => SyncWithSettingsError::AlreadyInProgress,
|
||||||
origin::SyncError::Unexpected(e) => SyncWithSettingsError::Unexpected(e),
|
origin::SyncError::Unexpected(e) => SyncWithSettingsError::Unexpected(e),
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,12 @@ use crate::util;
|
|||||||
|
|
||||||
#[derive(thiserror::Error, Clone, Debug, PartialEq)]
|
#[derive(thiserror::Error, Clone, Debug, PartialEq)]
|
||||||
pub enum SyncError {
|
pub enum SyncError {
|
||||||
#[error("invalid url")]
|
#[error("invalid descr")]
|
||||||
InvalidURL,
|
InvalidDescr(String),
|
||||||
|
|
||||||
#[error("unavailable due to server-side issue")]
|
#[error("unavailable due to upstream issue")]
|
||||||
Unavailable,
|
Unavailable,
|
||||||
|
|
||||||
#[error("invalid branch name")]
|
|
||||||
InvalidBranchName,
|
|
||||||
|
|
||||||
#[error("already in progress")]
|
#[error("already in progress")]
|
||||||
AlreadyInProgress,
|
AlreadyInProgress,
|
||||||
|
|
||||||
@ -33,7 +30,7 @@ pub enum GetFileError {
|
|||||||
#[error("file not found")]
|
#[error("file not found")]
|
||||||
FileNotFound,
|
FileNotFound,
|
||||||
|
|
||||||
#[error("unavailable due to server-side issue")]
|
#[error("unavailable due to upstream issue")]
|
||||||
Unavailable,
|
Unavailable,
|
||||||
|
|
||||||
#[error("path is directory")]
|
#[error("path is directory")]
|
||||||
|
@ -19,7 +19,7 @@ impl DescrState {
|
|||||||
|
|
||||||
#[derive(thiserror::Error, Clone, Debug, PartialEq)]
|
#[derive(thiserror::Error, Clone, Debug, PartialEq)]
|
||||||
enum GetObjectError {
|
enum GetObjectError {
|
||||||
#[error("unavailable due to server-side issue")]
|
#[error("unavailable due to upstream issue")]
|
||||||
Unavailable,
|
Unavailable,
|
||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
@ -84,15 +84,19 @@ impl Proxy {
|
|||||||
// (and therefore the URL) has some kind of issue.
|
// (and therefore the URL) has some kind of issue.
|
||||||
let refs = self
|
let refs = self
|
||||||
.client
|
.client
|
||||||
.get(refs_url)
|
.get(refs_url.clone())
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.or(Err(origin::SyncError::InvalidURL))?
|
.map_err(|e| {
|
||||||
|
origin::SyncError::InvalidDescr(format!("fetching refs from {refs_url}: {e}"))
|
||||||
|
})?
|
||||||
.error_for_status()
|
.error_for_status()
|
||||||
.or(Err(origin::SyncError::InvalidURL))?
|
.map_err(|e| {
|
||||||
|
origin::SyncError::InvalidDescr(format!("fetching refs from {refs_url}: {e}"))
|
||||||
|
})?
|
||||||
.text()
|
.text()
|
||||||
.await
|
.await
|
||||||
.or(Err(origin::SyncError::InvalidURL))?;
|
.or(Err(origin::SyncError::Unavailable))?;
|
||||||
|
|
||||||
let full_ref = format!("refs/heads/{}", branch_name);
|
let full_ref = format!("refs/heads/{}", branch_name);
|
||||||
for line in refs.lines() {
|
for line in refs.lines() {
|
||||||
@ -103,13 +107,15 @@ impl Proxy {
|
|||||||
return gix_hash::ObjectId::from_hex(
|
return gix_hash::ObjectId::from_hex(
|
||||||
line.split_ascii_whitespace()
|
line.split_ascii_whitespace()
|
||||||
.next()
|
.next()
|
||||||
.ok_or(origin::SyncError::InvalidURL)?
|
.ok_or(origin::SyncError::Unavailable)?
|
||||||
.as_bytes(),
|
.as_bytes(),
|
||||||
)
|
)
|
||||||
.or(Err(origin::SyncError::InvalidURL));
|
.or(Err(origin::SyncError::Unavailable));
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(origin::SyncError::InvalidBranchName)
|
Err(origin::SyncError::InvalidDescr(
|
||||||
|
"Invalid branch name".to_string(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_object(
|
async fn get_object(
|
||||||
|
@ -425,20 +425,12 @@ impl Service {
|
|||||||
(Some("This domain is not allowed to be configured.".to_string()), false)
|
(Some("This domain is not allowed to be configured.".to_string()), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(domain::manager::SyncWithSettingsError::InvalidURL) => (Some(
|
Err(domain::manager::SyncWithSettingsError::InvalidDescr(msg)) => (Some(
|
||||||
"Fetching the git repository failed; please double check that you input the correct
|
format!("Fetching the origin failed; please double check that you input the settings correctly. The error returned was: {msg}").to_string(),
|
||||||
URL."
|
|
||||||
.to_string(),
|
|
||||||
), false),
|
), false),
|
||||||
|
|
||||||
Err(domain::manager::SyncWithSettingsError::Unavailable) => (Some(
|
Err(domain::manager::SyncWithSettingsError::Unavailable) => (Some(
|
||||||
"Fetching the git repository failed; the server is not available or is not corectly serving the repository."
|
"Fetching the origin failed; the origin is not available or is behaving in an unexpected way."
|
||||||
.to_string(),
|
|
||||||
), false),
|
|
||||||
|
|
||||||
Err(domain::manager::SyncWithSettingsError::InvalidBranchName) => (Some(
|
|
||||||
"The git repository does not have a branch of the given name; please double check
|
|
||||||
that you input the correct name."
|
|
||||||
.to_string(),
|
.to_string(),
|
||||||
), false),
|
), false),
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user