2024-05-26 16:51:51 +01:00
|
|
|
//
|
|
|
|
pub type Result<T> = core::result::Result<T, Error>;
|
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[derive(Debug, thiserror::Error)]
|
2024-05-23 16:50:36 +01:00
|
|
|
pub enum Error {
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("lock")]
|
2024-05-26 16:51:51 +01:00
|
|
|
Lock,
|
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("File not found: {}", 0)]
|
2024-05-23 16:50:36 +01:00
|
|
|
NotFound(String),
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("Unable to parse file contents")]
|
2024-05-23 16:50:36 +01:00
|
|
|
ParseContent,
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("Unable to decode from base64")]
|
2024-05-23 16:50:36 +01:00
|
|
|
DecodeFromBase64,
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("Unable to decode from UTF-8")]
|
2024-05-23 16:50:36 +01:00
|
|
|
DecodeFromUtf8,
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("Unknown file encoding: {}", 0)]
|
2024-05-23 16:50:36 +01:00
|
|
|
UnknownEncoding(String),
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("Not a file: {}", 0)]
|
2024-05-23 16:50:36 +01:00
|
|
|
NotFile(String),
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("Unknown error (status: {})", 0)]
|
2024-05-23 16:50:36 +01:00
|
|
|
Unknown(String),
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("commit log: {0}")]
|
|
|
|
CommitLog(#[from] crate::commit::log::Error),
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("commit not found")]
|
2024-05-26 16:51:51 +01:00
|
|
|
CommitNotFound,
|
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("no tree in commit")]
|
2024-05-26 16:51:51 +01:00
|
|
|
NoTreeInCommit(String),
|
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("no .git-next.toml file found in repo")]
|
2024-05-26 16:51:51 +01:00
|
|
|
NoGitNextToml,
|
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("find reference: {0}")]
|
2024-05-26 16:51:51 +01:00
|
|
|
FindReference(String),
|
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("find object: {0}")]
|
2024-05-26 16:51:51 +01:00
|
|
|
FindObject(String),
|
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("Non-UTF-8 in blob: {0}")]
|
2024-05-26 16:51:51 +01:00
|
|
|
NonUtf8Blob(String),
|
|
|
|
|
2024-06-03 08:04:48 +01:00
|
|
|
#[error("try id")]
|
2024-05-26 16:51:51 +01:00
|
|
|
TryId,
|
2024-05-23 16:50:36 +01:00
|
|
|
}
|
2024-05-26 16:51:51 +01:00
|
|
|
|
2024-06-07 20:01:29 +01:00
|
|
|
mod gix_errors {
|
|
|
|
#![cfg(not(tarpaulin_include))] // third-party library errors
|
|
|
|
use super::Error;
|
|
|
|
impl From<gix::reference::find::existing::Error> for Error {
|
|
|
|
fn from(value: gix::reference::find::existing::Error) -> Self {
|
|
|
|
Self::FindReference(value.to_string())
|
|
|
|
}
|
2024-05-26 16:51:51 +01:00
|
|
|
}
|
|
|
|
|
2024-06-07 20:01:29 +01:00
|
|
|
impl From<gix::object::commit::Error> for Error {
|
|
|
|
fn from(value: gix::object::commit::Error) -> Self {
|
|
|
|
Self::NoTreeInCommit(value.to_string())
|
|
|
|
}
|
2024-05-26 16:51:51 +01:00
|
|
|
}
|
|
|
|
|
2024-06-07 20:01:29 +01:00
|
|
|
impl From<gix::object::find::existing::Error> for Error {
|
|
|
|
fn from(value: gix::object::find::existing::Error) -> Self {
|
|
|
|
Self::FindObject(value.to_string())
|
|
|
|
}
|
2024-05-26 16:51:51 +01:00
|
|
|
}
|
|
|
|
|
2024-06-07 20:01:29 +01:00
|
|
|
impl From<std::string::FromUtf8Error> for Error {
|
|
|
|
fn from(value: std::string::FromUtf8Error) -> Self {
|
|
|
|
Self::NonUtf8Blob(value.to_string())
|
|
|
|
}
|
2024-05-26 16:51:51 +01:00
|
|
|
}
|
|
|
|
}
|