httpd: Better error output from git backend

This commit is contained in:
cloudhead 2023-09-01 12:03:58 +02:00
parent 4fb5f6c172
commit 8ea9921765
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View File

@ -1,3 +1,5 @@
use std::process::ExitStatus;
use axum::http; use axum::http;
use axum::response::{IntoResponse, Response}; use axum::response::{IntoResponse, Response};
@ -21,8 +23,12 @@ pub enum GitError {
Id(#[from] radicle::identity::IdError), Id(#[from] radicle::identity::IdError),
/// Git backend error. /// Git backend error.
#[error("backend error")] #[error("git-http-backend: exited with code {0}")]
Backend, BackendExited(ExitStatus),
/// Git backend error.
#[error("git-http-backend: invalid header returned: {0:?}")]
BackendHeader(String),
/// HeaderName error. /// HeaderName error.
#[error(transparent)] #[error(transparent)]

View File

@ -168,7 +168,7 @@ async fn git_http_backend(
.or_insert_with(Vec::new) .or_insert_with(Vec::new)
.push(value.to_string()); .push(value.to_string());
} else { } else {
return Err(Error::Backend); return Err(Error::BackendHeader(line));
} }
} }
@ -191,12 +191,10 @@ async fn git_http_backend(
Ok((status, headers, body)) Ok((status, headers, body))
} }
Ok(output) => { Ok(output) => {
tracing::error!("git-http-backend: exited with code {}", output.status);
if let Ok(output) = std::str::from_utf8(&output.stderr) { if let Ok(output) = std::str::from_utf8(&output.stderr) {
tracing::error!("git-http-backend: stderr: {}", output.trim_end()); tracing::error!("git-http-backend: stderr: {}", output.trim_end());
} }
Err(Error::Backend) Err(Error::BackendExited(output.status))
} }
Err(err) => { Err(err) => {
panic!("failed to wait for git-http-backend: {err}"); panic!("failed to wait for git-http-backend: {err}");