Skip to main content

gpp_sync/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5    #[error("io error: {0}")]
6    Io(#[from] std::io::Error),
7    #[error("noise error: {0}")]
8    Noise(String),
9    #[error("protocol error: {0}")]
10    Protocol(String),
11    #[error("serialization error: {0}")]
12    Serde(#[from] serde_json::Error),
13    #[error("object store error: {0}")]
14    Core(#[from] gpp_core::Error),
15    #[error("repo id mismatch: local {local} != peer {remote}")]
16    RepoMismatch { local: String, remote: String },
17    #[error(
18        "peer key changed for {0:?} — refusing (TOFU). Remove it from .gpp/sync/known_peers to re-trust."
19    )]
20    PeerKeyChanged(String),
21    #[error("unauthorized peer static key {0} — not in the authorized-keys allowlist")]
22    Unauthorized(String),
23    #[error("{0}")]
24    Other(String),
25}
26
27pub type Result<T> = std::result::Result<T, Error>;