aboutsummaryrefslogtreecommitdiffstats
path: root/src/error
diff options
context:
space:
mode:
Diffstat (limited to 'src/error')
-rw-r--r--src/error/mod.rs165
1 files changed, 63 insertions, 102 deletions
diff --git a/src/error/mod.rs b/src/error/mod.rs
index 026cc58..f109e11 100644
--- a/src/error/mod.rs
+++ b/src/error/mod.rs
@@ -10,126 +10,87 @@
// You should have received a copy of the License along with this program.
// If not, see <https://www.gnu.org/licenses/agpl.txt>.
-use std::{fmt::Display, io, net::SocketAddr, path::PathBuf};
+use std::{io, net::SocketAddr, path::PathBuf};
-use gix::hash::Prefix;
+use git_bug::{
+ entities::{identity::Identity, issue::Issue},
+ replica::{
+ self,
+ entity::{
+ id::prefix::{self, IdPrefix},
+ snapshot::Snapshot,
+ },
+ },
+};
use thiserror::Error;
-pub type Result<T> = std::result::Result<T, Error>;
+pub(crate) type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
pub enum Error {
+ #[error("while trying to parse the config file ({file}): {error}")]
ConfigParse {
file: PathBuf,
error: serde_json::Error,
},
- ProjectListRead {
- file: PathBuf,
- error: io::Error,
- },
- ConfigRead {
- file: PathBuf,
- error: io::Error,
- },
- NotGitBug {
- path: PathBuf,
- },
+ #[error("while trying to read the project.list file ({file}): {error}")]
+ ProjectListRead { file: PathBuf, error: io::Error },
+
+ #[error("while trying to read the config file ({file}): {error}")]
+ ConfigRead { file: PathBuf, error: io::Error },
+
+ #[error("Repository ('{path}') has no initialized git-bug data")]
+ NotGitBug { path: PathBuf },
+
+ #[error("while trying to open the repository ({repository_path}): {error}")]
RepoOpen {
repository_path: PathBuf,
- error: Box<gix::open::Error>,
- },
- RepoFind {
- repository_path: PathBuf,
+ error: Box<replica::open::Error>,
},
+
+ #[error("while trying to get an entity reference from a replica: {0}")]
+ RepoGetReferences(#[from] replica::get::Error),
+
+ #[error("while trying to read an issues's data from a replica: {0}")]
+ RepoIssueRead(#[from] replica::entity::read::Error<Issue>),
+
+ #[error("while trying to read an identity's data from a replica: {0}")]
+ RepoIdentityRead(#[from] replica::entity::read::Error<Identity>),
+
+ #[error("failed to find the repository at path: '{repository_path}'")]
+ RepoFind { repository_path: PathBuf },
+
+ #[error("while iteration over the refs in a repository: {0}")]
RepoRefsIter(#[from] gix::refs::packed::buffer::open::Error),
- RepoRefsPrefixed {
- error: io::Error,
- },
- TcpBind {
- addr: SocketAddr,
- err: io::Error,
- },
- TcpAccept {
- err: io::Error,
- },
+ #[error("while prefixing the refs with a path: {error}")]
+ RepoRefsPrefixed { error: io::Error },
+
+ #[error("while trying to open tcp {addr} for listening: {err}.")]
+ TcpBind { addr: SocketAddr, err: io::Error },
+ #[error("while trying to accept a tcp connection: {err}.")]
+ TcpAccept { err: io::Error },
+
+ #[error("There is no 'issue' associated with the prefix '{prefix}': {err}")]
IssuesPrefixMissing {
- prefix: Prefix,
+ prefix: Box<IdPrefix>,
+ err: prefix::resolve::Error,
},
- IssuesPrefixParse(#[from] gix::hash::prefix::from_hex::Error),
-}
-impl Display for Error {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- match self {
- Error::ConfigParse { file, error } => {
- write!(
- f,
- "while trying to parse the config file ({}): {error}",
- file.display()
- )
- }
- Error::ProjectListRead { file, error } => {
- write!(
- f,
- "while trying to read the project.list file ({}): {error}",
- file.display()
- )
- }
- Error::ConfigRead { file, error } => {
- write!(
- f,
- "while trying to read the config file ({}): {error}",
- file.display()
- )
- }
- Error::RepoOpen {
- repository_path,
- error,
- } => {
- write!(
- f,
- "while trying to open the repository ({}): {error}",
- repository_path.display()
- )
- }
- Error::NotGitBug { path } => {
- write!(
- f,
- "Repository ('{}') has no initialized git-bug data",
- path.display()
- )
- }
- Error::RepoFind { repository_path } => {
- write!(
- f,
- "failed to find the repository at path: '{}'",
- repository_path.display()
- )
- }
- Error::RepoRefsIter(error) => {
- write!(f, "while iteration over the refs in a repository: {error}",)
- }
- Error::RepoRefsPrefixed { error, .. } => {
- write!(f, "while prefixing the refs with a path: {error}")
- }
- Error::IssuesPrefixMissing { prefix } => {
- write!(
- f,
- "There is no 'issue' associated with the prefix: {prefix}"
- )
- }
- Error::IssuesPrefixParse(error) => {
- write!(f, "The given prefix can not be parsed as prefix: {error}")
- }
- Error::TcpBind { addr, err } => {
- write!(f, "while trying to open tcp {addr} for listening: {err}.")
- }
- Error::TcpAccept { err } => {
- write!(f, "while trying to accept a tcp connection: {err}.")
- }
- }
- }
+ #[error("The given prefix ('{prefix}') can not be parsed as prefix: {error}")]
+ IssuesPrefixParse {
+ prefix: String,
+ error: prefix::decode::Error,
+ },
+
+ #[error("Route '{0}' was unknown.")]
+ NotFound(PathBuf),
+
+ #[error("Query '{query}' was not valid: {err}")]
+ InvalidQuery {
+ err: git_bug::query::parse::parser::Error<Snapshot<Issue>>,
+ query: String,
+ },
}