Skip to main content

jellyfish_reader/
error.rs

1use std::io;
2
3/// Errors that can occur when reading Jellyfish files.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// An I/O error occurred.
7    #[error("I/O error: {0}")]
8    Io(#[from] io::Error),
9
10    /// The file header could not be parsed.
11    #[error("invalid header: {0}")]
12    InvalidHeader(String),
13
14    /// The JSON in the header is malformed.
15    #[error("invalid header JSON: {0}")]
16    InvalidJson(#[from] serde_json::Error),
17
18    /// The file format is not supported.
19    #[error("unsupported format: {0}")]
20    UnsupportedFormat(String),
21
22    /// An invalid k-mer string was encountered.
23    #[error("invalid k-mer: {0}")]
24    InvalidKmer(String),
25
26    /// The file is truncated or corrupted.
27    #[error("unexpected end of file")]
28    UnexpectedEof,
29
30    /// A field is missing from the header.
31    #[error("missing header field: {0}")]
32    MissingField(String),
33}
34
35/// Result type alias for jellyfish-reader operations.
36pub type Result<T> = std::result::Result<T, Error>;