2ae9196
ZhenYi
feat(lib/git): add HTTP handler tree with routes and errors across analysis, archives, blobs, branches, commits, conflicts, content, diffs, hooks, lfs, logs, maintenance, packs, patches, pipelines, refs, remotes, repos, signatures, submodules, tags, trees
2ae9196
#[derive(Debug, thiserror::Error)]
pub enum SshError {
#[error("authentication rejected: {0}")]
AuthRejected(String),
#[error("failed to load host key: {0}")]
KeyLoadFailed(String),
#[error("repository not found: {0}")]
RepoNotFound(String),
#[error("permission denied: {0}")]
PermissionDenied(String),
#[error("invalid command: {0}")]
InvalidCommand(String),
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("database error: {0}")]
Db(#[from] sea_orm::DbErr),
#[error("ssh error: {0}")]
Ssh(#[from] russh::Error),
#[error("internal error: {0}")]
Internal(String),
}
pub type SshResult<T> = Result<T, SshError>;
impl From<crate::smart::error::SmartError> for SshError {
fn from(err: crate::smart::error::SmartError) -> Self {
use crate::smart::error::SmartError;
match err {
SmartError::Unauthorized => Self::AuthRejected("authentication required".into()),
SmartError::BadRequest(m) => Self::InvalidCommand(m),
SmartError::Conflict(m) => Self::Internal(m),
SmartError::Forbidden(m) => Self::PermissionDenied(m),
SmartError::NotFound(m) => Self::RepoNotFound(m),
SmartError::Internal(m) => Self::Internal(m),
SmartError::Io(e) => Self::Io(e),
SmartError::Db(e) => Self::Db(e),
SmartError::Redis(e) => Self::Internal(format!("redis error: {e}")),
}
}
}