Skip to main content

muster/
error.rs

1//! Error types for the muster library.
2
3use std::path::PathBuf;
4
5/// Errors produced by the muster library.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    #[error("tmux not found in PATH")]
9    TmuxNotFound,
10
11    #[error("tmux command failed: {0}")]
12    TmuxError(String),
13
14    #[error("IO error: {0}")]
15    Io(#[from] std::io::Error),
16
17    #[error("config directory error: {}", .0.display())]
18    ConfigDir(PathBuf),
19
20    #[error("profile not found: {0}")]
21    ProfileNotFound(String),
22
23    #[error("duplicate profile: {0}")]
24    DuplicateProfile(String),
25
26    #[error("session not found: {0}")]
27    SessionNotFound(String),
28
29    #[error("serialization error: {0}")]
30    Serialization(#[from] serde_json::Error),
31
32    #[error("invalid color: {0}")]
33    InvalidColor(String),
34
35    #[error("not inside a tmux session")]
36    NotInTmux,
37
38    #[error("not a muster-managed session")]
39    NotMusterSession,
40}
41
42/// Convenience alias for `std::result::Result` with [`Error`].
43pub type Result<T> = std::result::Result<T, Error>;