noosphere_core/context/sync/
error.rs

1use crate::api::v0alpha2::PushError;
2use thiserror::Error;
3
4/// Different classes of error that may occur during synchronization with a
5/// gateway
6#[derive(Error, Debug)]
7pub enum SyncError {
8    /// The error was a conflict; this is possibly recoverable
9    #[error("There was a conflict during sync")]
10    Conflict,
11    /// The error was some other, non-specific error
12    #[error("{0}")]
13    Other(anyhow::Error),
14}
15
16impl From<anyhow::Error> for SyncError {
17    fn from(value: anyhow::Error) -> Self {
18        SyncError::Other(value)
19    }
20}
21
22impl From<PushError> for SyncError {
23    fn from(value: PushError) -> Self {
24        match value {
25            PushError::Conflict => SyncError::Conflict,
26            any => SyncError::Other(any.into()),
27        }
28    }
29}