sapphire_framework_sync/
error.rs1use crate::report::PauseReason;
4
5#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 #[error("I/O error: {0}")]
9 Io(#[from] std::io::Error),
10 #[error("replica store error: {0}")]
11 Store(#[from] redb::Error),
12 #[error("serialization error: {0}")]
13 Json(#[from] serde_json::Error),
14 #[error("ignore file error: {0}")]
15 Ignore(#[from] ignore::Error),
16 #[error("replica store format {found} is newer than this build supports ({supported})")]
17 FormatTooNew { found: u32, supported: u32 },
18 #[error("replica store belongs to root {stored:?}, not {requested:?}")]
19 RootMismatch { stored: String, requested: String },
20 #[error("replica store is corrupt: {0}")]
21 Corrupt(String),
22 #[error("replica is paused: {0:?}")]
23 Paused(PauseReason),
24 #[cfg(any(test, feature = "test-util"))]
25 #[error("injected fault")]
26 InjectedFault,
27}
28
29pub type Result<T> = std::result::Result<T, Error>;
31
32pub(crate) trait RedbExt<T> {
34 fn db(self) -> Result<T>;
35}
36
37impl<T, E: Into<redb::Error>> RedbExt<T> for std::result::Result<T, E> {
38 fn db(self) -> Result<T> {
39 self.map_err(|e| Error::Store(e.into()))
40 }
41}