1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error)]
4pub enum ExtError {
5 #[error(
6 "{program} binary not found: not on PATH and {env_var} is not set. \
7 Install it from {install_hint} (conda: `conda install -c conda-forge {conda_pkg}`), \
8 or point {env_var} at the executable."
9 )]
10 BinaryNotFound {
11 program: &'static str,
12 env_var: &'static str,
13 install_hint: &'static str,
14 conda_pkg: &'static str,
15 },
16
17 #[error("{program} failed (exit status {status}): {stderr_tail}")]
18 SubprocessFailed {
19 program: &'static str,
20 status: String,
21 stderr_tail: String,
22 },
23
24 #[error("{program} did not produce the expected output file {path}")]
25 MissingOutput {
26 program: &'static str,
27 path: PathBuf,
28 },
29
30 #[error("parsing {what}: {message}")]
31 Parse { what: &'static str, message: String },
32
33 #[error("I/O error ({context}): {source}")]
34 Io {
35 context: String,
36 #[source]
37 source: std::io::Error,
38 },
39
40 #[error("conformer generation: {0}")]
41 ConfGen(String),
42}
43
44impl ExtError {
45 pub fn io(context: impl Into<String>, source: std::io::Error) -> Self {
46 ExtError::Io {
47 context: context.into(),
48 source,
49 }
50 }
51}