summaryrefslogtreecommitdiffstats
path: root/src/tmux
diff options
context:
space:
mode:
Diffstat (limited to 'src/tmux')
-rw-r--r--src/tmux/error.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/tmux/error.rs b/src/tmux/error.rs
new file mode 100644
index 0000000..c857e5b
--- /dev/null
+++ b/src/tmux/error.rs
@@ -0,0 +1,49 @@
+#[derive(Debug)]
+pub enum FormatError {
+ Path(String),
+ Timestamp(String),
+}
+
+#[derive(Debug)]
+pub enum Error {
+ IO(std::io::Error),
+ Utf8(std::str::Utf8Error),
+ PathFormat(String),
+ TimestampFormat(String),
+ ParseInt(std::num::ParseIntError),
+ NotFound,
+}
+
+impl std::error::Error for Error {}
+
+impl std::fmt::Display for Error {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ Error::IO(err) => write!(f, "IO error: {}", err),
+ Error::Utf8(err) => write!(f, "Failed to parse UTF8: {}", err),
+
+ Error::PathFormat(s) => write!(f, "Invalid path format: {}", s),
+ Error::TimestampFormat(s) => write!(f, "Invalid timestamp format: {}", s),
+ Error::ParseInt(err) => write!(f, "Failed to parse int: {}", err),
+ Error::NotFound => write!(f, "Tmux session not found"),
+ }
+ }
+}
+
+impl From<std::io::Error> for Error {
+ fn from(value: std::io::Error) -> Self {
+ Self::IO(value)
+ }
+}
+
+impl From<std::str::Utf8Error> for Error {
+ fn from(value: std::str::Utf8Error) -> Self {
+ Self::Utf8(value)
+ }
+}
+
+impl From<std::num::ParseIntError> for Error {
+ fn from(value: std::num::ParseIntError) -> Self {
+ Self::ParseInt(value)
+ }
+}