1use std::path::PathBuf;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7 #[error("no {kind} configuration found (looked in: {})", .searched.iter().map(|p| p.display().to_string()).collect::<Vec<_>>().join(", "))]
8 ConfigNotFound {
9 kind: &'static str,
10 searched: Vec<PathBuf>,
11 },
12
13 #[error("{path}: {message}")]
14 ConfigParse { path: PathBuf, message: String },
15
16 #[error("notmuch database.path is not set in {path}")]
17 NoDatabasePath { path: PathBuf },
18
19 #[error("maildir root {path} does not exist")]
20 MaildirMissing { path: PathBuf },
21
22 #[error("`{tool}` was not found on PATH")]
23 ToolMissing { tool: &'static str },
24
25 #[error("`{tool}` failed: {stderr}")]
26 ToolFailed { tool: &'static str, stderr: String },
27
28 #[error("no message with id {id}")]
29 MessageNotFound { id: String },
30
31 #[error("no part {part} in message {id}")]
32 PartNotFound { id: String, part: u32 },
33
34 #[error("could not parse message {id}: {message}")]
35 MessageParse { id: String, message: String },
36
37 #[error("invalid tag {tag:?}: {reason}")]
38 InvalidTag { tag: String, reason: &'static str },
39
40 #[error("no msmtp account named {account}")]
41 UnknownSendAccount { account: String },
42
43 #[error("cannot send this draft: {reason}")]
44 InvalidDraft { reason: String },
45
46 #[error("{path:?} is not a file ecr will read: {reason}")]
47 UnsafePath { path: String, reason: &'static str },
48
49 #[error(transparent)]
50 Io(#[from] std::io::Error),
51}