Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: return the error message not found errors
Fintan Halpenny committed 2 years ago
commit 64aded8bfdfa7093d0a1a373d0de9aef9a126d7f
parent 85be710155a5e499596fdc383ce75b2e56fdbf87
3 files changed +23 -13
modified radicle-httpd/src/api/error.rs
@@ -92,24 +92,30 @@ impl IntoResponse for Error {
        let message = self.to_string();
        let (status, msg) = match self {
            Error::NotFound => (StatusCode::NOT_FOUND, None),
-
            Error::CobStore(radicle::cob::store::Error::NotFound(_, _)) => {
-
                (StatusCode::NOT_FOUND, None)
+
            Error::CobStore(e @ radicle::cob::store::Error::NotFound(_, _)) => {
+
                (StatusCode::NOT_FOUND, Some(e.to_string()))
            }
            Error::Auth(msg) => (StatusCode::BAD_REQUEST, Some(msg.to_string())),
            Error::Crypto(msg) => (StatusCode::BAD_REQUEST, Some(msg.to_string())),
            Error::Surf(radicle_surf::Error::Git(e)) if radicle::git::is_not_found_err(&e) => {
-
                (StatusCode::NOT_FOUND, None)
+
                (StatusCode::NOT_FOUND, Some(e.message().to_owned()))
            }
            Error::Surf(radicle_surf::Error::Directory(
-
                radicle_surf::fs::error::Directory::PathNotFound(_),
-
            )) => (StatusCode::NOT_FOUND, None),
-
            Error::Git2(e) if radicle::git::is_not_found_err(&e) => (StatusCode::NOT_FOUND, None),
+
                e @ radicle_surf::fs::error::Directory::PathNotFound(_),
+
            )) => (StatusCode::NOT_FOUND, Some(e.to_string())),
+
            Error::Git2(e) if radicle::git::is_not_found_err(&e) => {
+
                (StatusCode::NOT_FOUND, Some(e.message().to_owned()))
+
            }
            Error::Git2(e) => (
                StatusCode::INTERNAL_SERVER_ERROR,
                Some(e.message().to_owned()),
            ),
-
            Error::Storage(err) if err.is_not_found() => (StatusCode::NOT_FOUND, None),
-
            Error::StorageRef(err) if err.is_not_found() => (StatusCode::NOT_FOUND, None),
+
            Error::Storage(err) if err.is_not_found() => {
+
                (StatusCode::NOT_FOUND, Some(err.to_string()))
+
            }
+
            Error::StorageRef(err) if err.is_not_found() => {
+
                (StatusCode::NOT_FOUND, Some(err.to_string()))
+
            }
            Error::BadRequest(msg) => (StatusCode::BAD_REQUEST, Some(msg)),
            other => {
                tracing::error!("Error: {message}");
modified radicle-httpd/src/api/v1/projects.rs
@@ -2128,7 +2128,7 @@ mod routes {
            Some(Body::from(body)),
            Some(SESSION_ID.to_string()),
        )
-
            .await;
+
        .await;

        assert_eq!(response.success().await, true);

modified radicle-httpd/src/test.rs
@@ -50,10 +50,14 @@ pub fn profile(home: &Path, seed: [u8; 32]) -> radicle::Profile {
    let keystore = Keystore::new(&home.keys());
    let keypair = KeyPair::from_seed(Seed::from(seed));
    let alias = node::Alias::new("seed");
-
    let storage = Storage::open(home.storage(), radicle::git::UserInfo {
-
        alias: alias.clone(),
-
        key: keypair.pk.into(),
-
    }).unwrap();
+
    let storage = Storage::open(
+
        home.storage(),
+
        radicle::git::UserInfo {
+
            alias: alias.clone(),
+
            key: keypair.pk.into(),
+
        },
+
    )
+
    .unwrap();

    radicle::storage::git::transport::local::register(storage.clone());
    keystore.store(keypair.clone(), "radicle", None).unwrap();