1#[derive(thiserror::Error, Debug, Clone)]
3pub enum AcquisitionError {
4 #[error("invalid path")]
6 InvalidPath,
7 #[error("already exists")]
9 AlreadyExists,
10 #[error("cannot create acquisition")]
12 CreationError,
13 #[error("cannot access some portion of the acquisition")]
15 AccessError(String),
16 #[error("bad event index")]
18 IndexOutOfBounds,
19 #[error("chunk is full")]
21 FullChunk,
22 #[error("failed to write data")]
24 WriteError,
25 #[error("metadata must be written before events")]
27 MetadataMissing,
28 #[error("cannot write metadata twice")]
30 MetadataAlreadyWritten,
31 #[error("invalid metadata")]
33 InvalidMetadata,
34 #[error("invalid calibration type")]
36 NoSuchMiscData,
37 #[error("unknown")]
39 Unknown,
40}
41
42#[derive(thiserror::Error, Debug)]
44pub enum MetadataError {
45 #[error("invalid metadata format")]
46 InvalidFormat,
47 #[error("invalid metadata format")]
48 InvalidName,
49 #[error("failed to serialized")]
50 SerializationError(#[from] serde_yaml::Error),
51}
52
53#[derive(Debug, thiserror::Error)]
55pub enum ParsingError {
56 #[error("provided parameters are invalid")]
57 InvalidParameters,
58 #[error("unexpected length of data")]
59 UnexpectedLength,
60 #[error("invalid channel number")]
61 InvalidChannel,
62 #[error("invalid window label")]
63 InvalidWindow,
64 #[error("required data missing when parsing")]
65 MissingData,
66 #[error("Encountered an empty Package which can't be parsed")]
67 PackageEmpty,
68 #[error("data is from an unsupported board model")]
69 UnsupportedModel,
70 #[error("unknown")]
71 Other,
72}
73
74#[derive(Debug, thiserror::Error)]
76pub enum ExportError {
77 #[error("invalid path")]
78 InvalidPath,
79 #[error("file access was denied")]
80 AccessDenied,
81 #[error("invalid format")]
82 InvalidFormat,
83 #[error("specified options are invalid for the data being exported")]
84 InvalidOptions,
85 #[error("error occurred while exporting as csv")]
86 CsvError(#[from] csv::Error),
87 #[error("error occurred while parsing")]
88 ParsingError(#[from] ParsingError),
89 #[error("error occurred while accessing acquisition")]
90 MetadataError(#[from] MetadataError),
91 #[error("unknown")]
92 Unknown,
93}
94
95impl From<std::io::Error> for ExportError {
96 fn from(e: std::io::Error) -> Self {
97 match e {
98 e if e.kind() == std::io::ErrorKind::NotFound => Self::InvalidPath,
99 e if e.kind() == std::io::ErrorKind::PermissionDenied => Self::AccessDenied,
100 _ => ExportError::Unknown,
101 }
102 }
103}
104
105#[derive(Debug, thiserror::Error)]
107pub enum MiscDataError {
108 #[error("invalid path")]
109 InvalidPath,
110 #[error("file access was denied")]
111 AccessDenied,
112 #[error("the misc data is invalid")]
113 InvalidMiscData,
114 #[error("serialization or deserialization failed")]
115 SerializationError(#[from] serde_pickle::Error),
116 #[error("unknown")]
117 Unknown,
118}
119
120impl From<std::io::Error> for MiscDataError {
121 fn from(e: std::io::Error) -> Self {
122 match e {
123 e if e.kind() == std::io::ErrorKind::NotFound => Self::InvalidPath,
124 e if e.kind() == std::io::ErrorKind::PermissionDenied => Self::AccessDenied,
125 e if e.kind() == std::io::ErrorKind::InvalidData => Self::InvalidMiscData,
126 e if e.kind() == std::io::ErrorKind::UnexpectedEof => Self::InvalidMiscData,
127 _ => MiscDataError::Unknown,
128 }
129 }
130}
131
132#[derive(Debug, thiserror::Error)]
134pub enum CalibrationError {
135 #[error("pedestals correction failed")]
136 PedestalsCorrectionFailed,
137 #[error("invalid data shape")]
138 InvalidDataShape,
139}