1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum ClusteringError {
8 #[error("empty input: cannot cluster zero hits")]
10 EmptyInput,
11
12 #[error("invalid configuration: {0}")]
14 InvalidConfig(String),
15
16 #[error("state error: {0}")]
18 StateError(String),
19}
20
21#[derive(Error, Debug)]
23pub enum ExtractionError {
24 #[error("empty cluster: cannot extract from zero hits")]
26 EmptyCluster,
27
28 #[error("invalid configuration: {0}")]
30 InvalidConfig(String),
31}
32
33#[derive(Error, Debug)]
35pub enum IoError {
36 #[error("file not found: {0}")]
38 FileNotFound(String),
39
40 #[error("invalid file format: {0}")]
42 InvalidFormat(String),
43
44 #[error("memory mapping failed: {0}")]
46 MmapError(String),
47
48 #[error("I/O error: {0}")]
50 Io(#[from] std::io::Error),
51}
52
53#[derive(Error, Debug)]
55pub enum ProcessingError {
56 #[error("I/O error: {0}")]
58 Io(#[from] IoError),
59
60 #[error("invalid packet at offset {offset}: {message}")]
62 InvalidPacket {
63 offset: usize,
65 message: String,
67 },
68
69 #[error("missing TDC reference for section starting at offset {0}")]
71 MissingTdc(usize),
72
73 #[error("configuration error: {0}")]
75 Config(String),
76}
77
78#[derive(Error, Debug)]
80pub enum Error {
81 #[error("clustering error: {0}")]
83 Clustering(#[from] ClusteringError),
84
85 #[error("extraction error: {0}")]
87 Extraction(#[from] ExtractionError),
88
89 #[error("I/O error: {0}")]
91 Io(#[from] IoError),
92
93 #[error("processing error: {0}")]
95 Processing(#[from] ProcessingError),
96}
97
98pub type Result<T> = std::result::Result<T, Error>;