1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Error {
5 #[error("DataLog io error: {0:?}")]
6 Io(#[from] std::io::Error),
7 #[error("Record serialization error: {0:?}")]
8 RecordSerialize(String),
9 #[error("Record deserialization error: {0:?}")]
10 RecordDeserialize(String),
11 #[error("Record type error: {0:?}")]
12 RecordType(String),
13 #[error("Record byte reader was short: {0}")]
14 RecordReaderOutOfBounds(&'static str),
15 #[error("Attempted to modify a read only data log")]
16 DataLogReadOnly,
17 #[error("DataLog entry does not exist")]
18 NoSuchEntry,
19 #[error("Outside entry lifetime")]
20 OutsideEntryLifetime,
21 #[error("DataLog entry already exists")]
22 EntryAlreadyExists,
23 #[error("Dile not a valid DataLog")]
24 InvalidDataLog,
25 #[error("File doesn't exist")]
26 FileDoesNotExist,
27 #[error("File already exists")]
28 FileAlreadyExists,
29 #[error("Retro entry data")]
30 RetroEntryData,
31}
32
33#[inline(always)]
34pub(crate) fn log_result<T, E: std::error::Error>(result: Result<T, E>) -> Result<T, E> {
35 #[cfg(feature = "tracing")]
36 match &result {
37 Err(err) => {
38 tracing::error!("{}", err)
39 }
40 _ => {}
41 };
42 result
43}