1use thiserror::Error;
2
3#[derive(Debug, Error)]
5#[non_exhaustive]
6pub enum TuiError {
7 #[error("terminal error: {0}")]
9 Terminal(#[from] std::io::Error),
10 #[error("clap error: {0}")]
12 Clap(#[from] clap::Error),
13 #[error("runner error: {0}")]
15 Runner(Box<dyn std::error::Error + Send + Sync>),
16 #[error("cancelled")]
21 Cancelled,
22 #[error("{}", unknown_entrypoint_message(name, candidates))]
24 UnknownEntrypoint {
25 name: String,
27 candidates: Vec<String>,
29 },
30}
31
32fn unknown_entrypoint_message(name: &str, candidates: &[String]) -> String {
33 if candidates.is_empty() {
34 format!("unknown TUI entrypoint `{name}`; no top-level subcommands are available")
35 } else {
36 format!(
37 "unknown TUI entrypoint `{name}`; expected one of: {}",
38 candidates.join(", ")
39 )
40 }
41}