diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-26 17:50:54 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-26 17:58:27 +0100 |
commit | dfb5714045e99a09bf3f67890ae3cdeab47058b3 (patch) | |
tree | 5e76e310892ea7e36099312e25023aa154217a28 /pkgs/by-name/ba/back/src/error/mod.rs | |
parent | fix(pkgs/back): Use rocket to manage the configuration values (diff) | |
download | nixos-server-dfb5714045e99a09bf3f67890ae3cdeab47058b3.zip |
feat(pkgs/back): Rewrite the `git-bug` interface code
The previous code was more or less reverse engineered, whilst this code is based on the actually git-bug source code. This improves the whole issue and operation handling immensely and also makes the code better maintainable. Furthermore, it also adds support for the operations that had not already used in `vhack.eu/nixos-server.git`.
Diffstat (limited to 'pkgs/by-name/ba/back/src/error/mod.rs')
-rw-r--r-- | pkgs/by-name/ba/back/src/error/mod.rs | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/pkgs/by-name/ba/back/src/error/mod.rs b/pkgs/by-name/ba/back/src/error/mod.rs index 7e1c9cf..8b71700 100644 --- a/pkgs/by-name/ba/back/src/error/mod.rs +++ b/pkgs/by-name/ba/back/src/error/mod.rs @@ -1,9 +1,24 @@ +// 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 std::{fmt::Display, io, path::PathBuf}; 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 { @@ -14,11 +29,19 @@ pub enum Error { file: PathBuf, error: io::Error, }, + RocketLaunch(#[from] rocket::Error), + RepoOpen { repository_path: PathBuf, error: Box<gix::open::Error>, }, - RocketLaunch(#[from] rocket::Error), + RepoRefsIter(#[from] gix::refs::packed::buffer::open::Error), + RepoRefsPrefixed(#[from] std::io::Error), + + IssuesPrefixMissing { + prefix: BackPrefix, + }, + IssuesPrefixParse(#[from] gix::hash::prefix::from_hex::Error), } impl Display for Error { @@ -38,6 +61,9 @@ impl Display for Error { file.display() ) } + Error::RocketLaunch(error) => { + write!(f, "while trying to start back: {error}") + } Error::RepoOpen { repository_path, error, @@ -48,8 +74,20 @@ impl Display for Error { repository_path.display() ) } - Error::RocketLaunch(error) => { - write!(f, "while trying to start back: {error}") + 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}") } } } |