Skip to main content

mafft_io/
error.rs

1use std::io;
2
3#[derive(Debug, thiserror::Error)]
4pub enum IoError {
5    #[error("I/O error: {0}")]
6    Io(#[from] io::Error),
7
8    #[error("FASTA parse error: {0}")]
9    FastaParse(String),
10
11    #[error("hat2 format error: {0}")]
12    Hat2Format(String),
13
14    #[error("localhom format error: {0}")]
15    LocalHomFormat(String),
16
17    #[error("no sequences found in input")]
18    EmptyInput,
19
20    /// A description line preceded by blanks (`^[[:blank:]]+>`). C MAFFT
21    /// rejects the whole input (`scripts/mafft:1827-1834`, exit 1); a
22    /// lenient parser would silently fold the line into the previous
23    /// sequence. `line` is 1-based, `text` the offending line verbatim.
24    #[error("The first character of a description line must be \nthe greater-than (>) symbol, not a blank.\nPlease check the format around the following line(s):\n{line}:{text}")]
25    BlankBeforeHeader { line: usize, text: String },
26
27    /// `=`, `<` or `>` inside a sequence line on the case-preserving
28    /// (`--anysymbol` / `--preservecase`) path. C's `charfilter`
29    /// (`io.c:1329-1352`) exits 1 on these because `readData_pointer`
30    /// uses them as record markers.
31    #[error("Characters '= < >' can be used only in the title lines in the --anysymbol or --text mode.")]
32    IllegalTitleCharInSequence,
33
34    #[error("sequence count mismatch: expected {expected}, got {got}")]
35    SeqCountMismatch { expected: usize, got: usize },
36}