diff options
Diffstat (limited to 'pkgs/by-name/ba/back/src/error')
-rw-r--r-- | pkgs/by-name/ba/back/src/error/mod.rs | 94 | ||||
-rw-r--r-- | pkgs/by-name/ba/back/src/error/responder.rs | 23 |
2 files changed, 0 insertions, 117 deletions
diff --git a/pkgs/by-name/ba/back/src/error/mod.rs b/pkgs/by-name/ba/back/src/error/mod.rs deleted file mode 100644 index 8b71700..0000000 --- a/pkgs/by-name/ba/back/src/error/mod.rs +++ /dev/null @@ -1,94 +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 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 { - file: PathBuf, - error: serde_json::Error, - }, - ConfigRead { - file: PathBuf, - error: io::Error, - }, - RocketLaunch(#[from] rocket::Error), - - RepoOpen { - repository_path: PathBuf, - error: Box<gix::open::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 { - 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::ConfigRead { file, error } => { - write!( - f, - "while trying to read the config file ({}): {error}", - file.display() - ) - } - Error::RocketLaunch(error) => { - write!(f, "while trying to start back: {error}") - } - Error::RepoOpen { - repository_path, - error, - } => { - write!( - f, - "while trying to open the repository ({}): {error}", - 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}") - } - } - } -} 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() - } -} |