2024-05-26 16:51:51 +01:00
|
|
|
//
|
|
|
|
pub type Result<T> = core::result::Result<T, Error>;
|
|
|
|
|
2024-05-23 16:50:36 +01:00
|
|
|
#[derive(Debug, derive_more::Display)]
|
|
|
|
pub enum Error {
|
2024-05-26 16:51:51 +01:00
|
|
|
Lock,
|
|
|
|
|
2024-05-23 16:50:36 +01:00
|
|
|
#[display("File not found: {}", 0)]
|
|
|
|
NotFound(String),
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-05-23 16:50:36 +01:00
|
|
|
#[display("Unable to parse file contents")]
|
|
|
|
ParseContent,
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-05-23 16:50:36 +01:00
|
|
|
#[display("Unable to decode from base64")]
|
|
|
|
DecodeFromBase64,
|
2024-05-26 16:51:51 +01:00
|
|
|
|
|
|
|
#[display("Unable to decode from UTF-8")]
|
2024-05-23 16:50:36 +01:00
|
|
|
DecodeFromUtf8,
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-05-23 16:50:36 +01:00
|
|
|
#[display("Unknown file encoding: {}", 0)]
|
|
|
|
UnknownEncoding(String),
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-05-23 16:50:36 +01:00
|
|
|
#[display("Not a file: {}", 0)]
|
|
|
|
NotFile(String),
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-05-23 16:50:36 +01:00
|
|
|
#[display("Unknown error (status: {})", 0)]
|
|
|
|
Unknown(String),
|
2024-05-26 16:51:51 +01:00
|
|
|
|
|
|
|
CommitLog(crate::commit::log::Error),
|
|
|
|
|
|
|
|
CommitNotFound,
|
|
|
|
|
|
|
|
NoTreeInCommit(String),
|
|
|
|
|
|
|
|
NoGitNextToml,
|
|
|
|
|
|
|
|
FindReference(String),
|
|
|
|
|
|
|
|
FindObject(String),
|
|
|
|
|
|
|
|
NonUtf8Blob(String),
|
|
|
|
|
|
|
|
TryId,
|
2024-05-23 16:50:36 +01:00
|
|
|
}
|
|
|
|
impl std::error::Error for Error {}
|
2024-05-26 16:51:51 +01:00
|
|
|
|
|
|
|
impl From<crate::commit::log::Error> for Error {
|
|
|
|
fn from(value: crate::commit::log::Error) -> Self {
|
|
|
|
Self::CommitLog(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl From<gix::reference::find::existing::Error> for Error {
|
|
|
|
fn from(value: gix::reference::find::existing::Error) -> Self {
|
|
|
|
Self::FindReference(value.to_string())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gix::object::commit::Error> for Error {
|
|
|
|
fn from(value: gix::object::commit::Error) -> Self {
|
|
|
|
Self::NoTreeInCommit(value.to_string())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gix::object::find::existing::Error> for Error {
|
|
|
|
fn from(value: gix::object::find::existing::Error) -> Self {
|
|
|
|
Self::FindObject(value.to_string())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::string::FromUtf8Error> for Error {
|
|
|
|
fn from(value: std::string::FromUtf8Error) -> Self {
|
|
|
|
Self::NonUtf8Blob(value.to_string())
|
|
|
|
}
|
|
|
|
}
|