radicle_protocol/worker/fetch/
error.rs1use std::io;
2
3use thiserror::Error;
4
5use radicle::{cob, git::raw, identity, storage};
6use radicle_fetch as fetch;
7
8#[derive(Debug, Error)]
9pub enum Fetch {
10 #[error(transparent)]
11 Run(#[from] fetch::Error),
12 #[error(transparent)]
13 Git(#[from] raw::Error),
14 #[error(transparent)]
15 Storage(#[from] storage::Error),
16 #[error(transparent)]
17 StorageCopy(#[from] io::Error),
18 #[error(transparent)]
19 Repository(#[from] radicle::storage::RepositoryError),
20 #[error(transparent)]
21 RefsDb(Box<radicle::node::refs::Error>),
22 #[error("validation of the storage repository failed: the delegates {delegates:?} failed to validate to meet a threshold of {threshold}")]
23 Validation {
24 threshold: usize,
25 delegates: Vec<String>,
26 },
27 #[error(transparent)]
28 Cache(#[from] Cache),
29}
30
31impl From<radicle::node::refs::Error> for Fetch {
32 fn from(err: radicle::node::refs::Error) -> Self {
33 Self::RefsDb(Box::new(err))
34 }
35}
36
37#[derive(Debug, Error)]
38pub enum Cache {
39 #[error(transparent)]
40 Parse(#[from] cob::ParseIdentifierError),
41 #[error(transparent)]
42 Repository(#[from] storage::RepositoryError),
43 #[error("failed to remove {type_name} '{id}' from cache: {err}")]
44 Remove {
45 id: cob::ObjectId,
46 type_name: cob::TypeName,
47 #[source]
48 err: Box<dyn std::error::Error + Send + Sync + 'static>,
49 },
50 #[error(transparent)]
51 Store(#[from] cob::store::Error),
52 #[error("failed to update {type_name} '{id}' in cache: {err}")]
53 Update {
54 id: cob::ObjectId,
55 type_name: cob::TypeName,
56 #[source]
57 err: Box<dyn std::error::Error + Send + Sync + 'static>,
58 },
59}
60
61#[derive(Debug, Error)]
62pub enum Handle {
63 #[error(transparent)]
64 Doc(#[from] identity::DocError),
65 #[error(transparent)]
66 Io(#[from] io::Error),
67 #[error(transparent)]
68 Init(#[from] fetch::handle::error::Init),
69 #[error(transparent)]
70 Storage(#[from] storage::Error),
71 #[error(transparent)]
72 Repository(#[from] radicle::storage::RepositoryError),
73}
74
75#[derive(Debug, Error)]
76pub enum Canonical {
77 #[error(transparent)]
78 Identity(#[from] radicle::storage::RepositoryError),
79 #[error(transparent)]
80 CanonicalRefs(#[from] radicle::identity::doc::CanonicalRefsError),
81}