graft_kernel/
err.rs

1use crate::{local::fjall_storage::FjallStorageErr, remote::RemoteErr};
2use graft_core::VolumeId;
3
4#[derive(Debug, thiserror::Error)]
5pub enum KernelErr {
6    #[error(transparent)]
7    Storage(FjallStorageErr),
8
9    #[error(transparent)]
10    Remote(#[from] RemoteErr),
11
12    #[error(transparent)]
13    Logical(#[from] LogicalErr),
14}
15
16impl From<FjallStorageErr> for KernelErr {
17    fn from(value: FjallStorageErr) -> Self {
18        match value {
19            FjallStorageErr::LogicalErr(verr) => KernelErr::Logical(verr),
20            other => KernelErr::Storage(other),
21        }
22    }
23}
24
25#[derive(Debug, thiserror::Error)]
26pub enum LogicalErr {
27    #[error("Unknown Volume {0}")]
28    VolumeNotFound(VolumeId),
29
30    #[error("Concurrent write to Graft {0}")]
31    GraftConcurrentWrite(VolumeId),
32
33    #[error("Graft {0} not found")]
34    GraftNotFound(VolumeId),
35
36    #[error("Graft {0} has a pending commit and needs recovery")]
37    GraftNeedsRecovery(VolumeId),
38
39    #[error("Graft {0} has diverged from the remote")]
40    GraftDiverged(VolumeId),
41
42    #[error(
43        "Graft `{graft}` has a different remote Volume than expected; expected={expected}, actual={actual}"
44    )]
45    GraftRemoteMismatch {
46        graft: VolumeId,
47        expected: VolumeId,
48        actual: VolumeId,
49    },
50}