Add ObjectParseError
In Create a git object module we said that read
function to read objects has this signature:
pub fn read(repo: &GitRepository, sha: String) -> Result<Box<dyn GitObject>, ObjectParseError> {
We covered the first part of the return type in Add BlobObject, now we need to add a new error type, ObjectParseError:
// src/error.rs
#[derive(Debug, Error)]
pub enum ObjectParseError {
#[error("Object type is not valid")]
InvalidObjectType,
#[error(transparent)]
InvalidObjectSize(#[from] ParseIntError),
#[error("Header size differs from the actual read bytes")]
MismatchedObjectSize,
#[error(transparent)]
UnexpectedError(#[from] anyhow::Error),
#[error(transparent)]
IoError(#[from] std::io::Error),
}
Last updated