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
use std::fmt;
use oxcache::error::OxCacheError;
#[derive(Debug)]
pub enum CacheError {
InvalidConfig(String),
Serialization(String),
Backend(OxCacheError),
}
impl fmt::Display for CacheError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
CacheError::InvalidConfig(msg) => write!(f, "invalid cache config: {msg}"),
CacheError::Serialization(msg) => write!(f, "cache serialization error: {msg}"),
CacheError::Backend(err) => write!(f, "cache backend error: {err}"),
}
}
}
impl std::error::Error for CacheError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
CacheError::Backend(err) => Some(err),
_ => None,
}
}
}
impl From<OxCacheError> for CacheError {
fn from(err: OxCacheError) -> Self {
CacheError::Backend(err)
}
}
impl From<serde_json::Error> for CacheError {
fn from(err: serde_json::Error) -> Self {
CacheError::Serialization(err.to_string())
}
}