1pub mod core;
3
4pub mod domain;
6
7pub mod adapters;
9
10pub mod commands;
12
13pub mod cli;
15
16#[cfg(test)]
18pub mod examples;
19
20#[derive(Debug)]
22pub enum GitXError {
23 GitCommand(String),
24 Io(std::io::Error),
25 Parse(String),
26 Dialog(String),
27 Join(String),
28}
29
30impl std::fmt::Display for GitXError {
31 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32 match self {
33 GitXError::GitCommand(cmd) => write!(f, "Git command failed: {cmd}"),
34 GitXError::Io(err) => write!(f, "IO error: {err}"),
35 GitXError::Parse(msg) => write!(f, "Parse error: {msg}"),
36 GitXError::Dialog(msg) => write!(f, "Dialog error: {msg}"),
37 GitXError::Join(msg) => write!(f, "Join error: {msg}"),
38 }
39 }
40}
41
42impl std::error::Error for GitXError {
43 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
44 match self {
45 GitXError::Io(err) => Some(err),
46 GitXError::GitCommand(_)
47 | GitXError::Parse(_)
48 | GitXError::Dialog(_)
49 | GitXError::Join(_) => None,
50 }
51 }
52}
53
54impl From<std::io::Error> for GitXError {
55 fn from(err: std::io::Error) -> Self {
56 GitXError::Io(err)
57 }
58}
59
60impl From<dialoguer::Error> for GitXError {
61 fn from(err: dialoguer::Error) -> Self {
62 GitXError::Dialog(err.to_string())
63 }
64}
65
66impl From<tokio::task::JoinError> for GitXError {
67 fn from(err: tokio::task::JoinError) -> Self {
68 GitXError::Join(err.to_string())
69 }
70}
71
72pub type Result<T> = std::result::Result<T, GitXError>;