Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Better error output from git backend
cloudhead committed 2 years ago
commit 05f75f2c0288839cf924b3eccfeba52141febac5
parent b96fbac3f065b7149b5d2f197216e213fea5cf96
2 files changed +10 -6
modified radicle-httpd/src/error.rs
@@ -1,3 +1,5 @@
+
use std::process::ExitStatus;
+

use axum::http;
use axum::response::{IntoResponse, Response};

@@ -21,8 +23,12 @@ pub enum GitError {
    Id(#[from] radicle::identity::IdError),

    /// Git backend error.
-
    #[error("backend error")]
-
    Backend,
+
    #[error("git-http-backend: exited with code {0}")]
+
    BackendExited(ExitStatus),
+

+
    /// Git backend error.
+
    #[error("git-http-backend: invalid header returned: {0:?}")]
+
    BackendHeader(String),

    /// HeaderName error.
    #[error(transparent)]
modified radicle-httpd/src/git.rs
@@ -168,7 +168,7 @@ async fn git_http_backend(
                        .or_insert_with(Vec::new)
                        .push(value.to_string());
                } else {
-
                    return Err(Error::Backend);
+
                    return Err(Error::BackendHeader(line));
                }
            }

@@ -191,12 +191,10 @@ async fn git_http_backend(
            Ok((status, headers, body))
        }
        Ok(output) => {
-
            tracing::error!("git-http-backend: exited with code {}", output.status);
-

            if let Ok(output) = std::str::from_utf8(&output.stderr) {
                tracing::error!("git-http-backend: stderr: {}", output.trim_end());
            }
-
            Err(Error::Backend)
+
            Err(Error::BackendExited(output.status))
        }
        Err(err) => {
            panic!("failed to wait for git-http-backend: {err}");