aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ba/back/src/error
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/ba/back/src/error/mod.rs66
-rw-r--r--pkgs/by-name/ba/back/src/error/responder.rs23
2 files changed, 53 insertions, 36 deletions
diff --git a/pkgs/by-name/ba/back/src/error/mod.rs b/pkgs/by-name/ba/back/src/error/mod.rs
index 8b71700..8889033 100644
--- a/pkgs/by-name/ba/back/src/error/mod.rs
+++ b/pkgs/by-name/ba/back/src/error/mod.rs
@@ -9,37 +9,53 @@
// 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, path::PathBuf};
+use std::{fmt::Display, io, net::SocketAddr, path::PathBuf};
+use gix::hash::Prefix;
use thiserror::Error;
-use crate::web::prefix::BackPrefix;
-
pub type Result<T> = std::result::Result<T, Error>;
-pub mod responder;
-
#[derive(Error, Debug)]
pub enum Error {
ConfigParse {
file: PathBuf,
error: serde_json::Error,
},
+
+ ProjectListRead {
+ file: PathBuf,
+ error: io::Error,
+ },
ConfigRead {
file: PathBuf,
error: io::Error,
},
- RocketLaunch(#[from] rocket::Error),
-
+ NotGitBug {
+ path: PathBuf,
+ },
RepoOpen {
repository_path: PathBuf,
error: Box<gix::open::Error>,
},
+ RepoFind {
+ repository_path: PathBuf,
+ },
RepoRefsIter(#[from] gix::refs::packed::buffer::open::Error),
- RepoRefsPrefixed(#[from] std::io::Error),
+ RepoRefsPrefixed {
+ error: io::Error,
+ },
+
+ TcpBind {
+ addr: SocketAddr,
+ err: io::Error,
+ },
+ TcpAccept {
+ err: io::Error,
+ },
IssuesPrefixMissing {
- prefix: BackPrefix,
+ prefix: Prefix,
},
IssuesPrefixParse(#[from] gix::hash::prefix::from_hex::Error),
}
@@ -54,6 +70,13 @@ impl Display for 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,
@@ -61,9 +84,6 @@ impl Display for Error {
file.display()
)
}
- Error::RocketLaunch(error) => {
- write!(f, "while trying to start back: {error}")
- }
Error::RepoOpen {
repository_path,
error,
@@ -74,10 +94,24 @@ impl Display for 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) => {
+ Error::RepoRefsPrefixed { error, .. } => {
write!(f, "while prefixing the refs with a path: {error}")
}
Error::IssuesPrefixMissing { prefix } => {
@@ -89,6 +123,12 @@ impl Display for Error {
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}.")
+ }
}
}
}
diff --git a/pkgs/by-name/ba/back/src/error/responder.rs b/pkgs/by-name/ba/back/src/error/responder.rs
deleted file mode 100644
index 7bea961..0000000
--- a/pkgs/by-name/ba/back/src/error/responder.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Back - An extremely simple git issue tracking system. Inspired by tvix's
-// panettone
-//
-// Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
-// SPDX-License-Identifier: AGPL-3.0-or-later
-//
-// This file is part of Back.
-//
-// You should have received a copy of the License along with this program.
-// If not, see <https://www.gnu.org/licenses/agpl.txt>.
-
-use rocket::{
- response::{self, Responder, Response},
- Request,
-};
-
-use super::Error;
-
-impl<'r> Responder<'r, 'static> for Error {
- fn respond_to(self, req: &'r Request<'_>) -> response::Result<'static> {
- Response::build_from(self.to_string().respond_to(req)?).ok()
- }
-}