Skip to main content

gapsmith_align/
error.rs

1//! Error type shared by every aligner backend.
2
3use std::path::PathBuf;
4use std::process::ExitStatus;
5
6#[derive(Debug, thiserror::Error)]
7pub enum AlignError {
8    #[error("external tool `{tool}` not found on PATH")]
9    ToolMissing { tool: &'static str },
10
11    #[error("external tool `{tool}` exited with {status}: {stderr}")]
12    ToolFailed {
13        tool: &'static str,
14        status: ExitStatus,
15        stderr: String,
16    },
17
18    #[error("i/o error on `{path}`: {source}")]
19    Io {
20        path: PathBuf,
21        #[source]
22        source: std::io::Error,
23    },
24
25    #[error("TSV parse error on line {line}: {msg}")]
26    TsvParse { line: u64, msg: String },
27
28    #[error("unsupported argument: {0}")]
29    BadArg(String),
30}
31
32pub(crate) fn io_err(path: &std::path::Path, source: std::io::Error) -> AlignError {
33    AlignError::Io { path: path.to_path_buf(), source }
34}