radicle-surf: reorganise errors

The current `error::Error` type aggregated a lot of different error
scenarios that were not for the actual repo actions, instead they
would be for the domains that the repo actions would return.

This is a reorganisation of those by localising error variants in
their modules:
* namespace::Error
* commit::Error
* glob::Error
* adding `type Error` to ToCommit
* adding `type Error` to Revision

The main Error type now consists of these other Error types and lives
in the `repo` module. It is re-exported at the top-level since
RepositoryRef is the main interaction with the library.

During this refactor, some reorganisation of functions was done as
well:
* Move `get_file` from `Commit` to `RepositoryRef` as
`get_commit_file`.
* Have a blanket implementation of `ToCommit` for any `Revision`,
instead of repeating the implementations.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2022-11-18 10:39:15 +00:00
parent 0d1bfb89a2
commit 42093a2fe1
12 changed files with 217 additions and 230 deletions
+5 -2
View File
@@ -27,7 +27,7 @@ use serde::{
use crate::{
diff,
file_system,
git::{self, Glob, RepositoryRef},
git::{self, glob, Glob, RepositoryRef},
person::Person,
revision::Revision,
};
@@ -251,7 +251,10 @@ pub enum Error {
/// An error occurred during a git operation.
#[error(transparent)]
Git(#[from] git::error::Error),
Git(#[from] git::Error),
#[error(transparent)]
Glob(#[from] glob::Error),
/// Trying to find a file path which could not be found.
#[error("the path '{0}' was not found")]