about summary refs log tree commit diff stats
path: root/pkgs/by-name/ba/back/src/error/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/ba/back/src/error/mod.rs')
-rw-r--r--pkgs/by-name/ba/back/src/error/mod.rs66
1 files changed, 53 insertions, 13 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}.")
+            }
         }
     }
 }