httpd: Fix more routes that return the wrong code

These routes should return 404 if the entity was not found.
This commit is contained in:
cloudhead
2023-08-09 16:59:19 +02:00
parent 1a81c704bc
commit a2c84f36bf
5 changed files with 87 additions and 25 deletions
+8
View File
@@ -93,11 +93,19 @@ impl IntoResponse for Error {
}
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)
}
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),
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::BadRequest(msg) => (StatusCode::BAD_REQUEST, Some(msg)),
other => {
tracing::error!("Error: {message}");