p2panda_rs/storage_provider/
error.rs1use crate::document::error::DocumentBuilderError;
5use crate::document::{DocumentId, DocumentViewId};
6use crate::entry::error::{LogIdError, SeqNumError, ValidateEntryError};
7use crate::hash::error::HashError;
8use crate::hash::Hash;
9use crate::identity::error::PublicKeyError;
10use crate::operation::error::ValidateOperationError;
11use crate::operation::OperationId;
12
13#[derive(thiserror::Error, Debug)]
15pub enum ValidationError {
16 #[error(transparent)]
18 AuthorValidation(#[from] PublicKeyError),
19
20 #[error(transparent)]
22 HashValidation(#[from] HashError),
23
24 #[error(transparent)]
26 EntryValidation(#[from] ValidateEntryError),
27
28 #[error(transparent)]
30 OperationValidation(#[from] ValidateOperationError),
31
32 #[error(transparent)]
34 LogIdValidation(#[from] LogIdError),
35
36 #[error(transparent)]
38 SeqNumValidation(#[from] SeqNumError),
39
40 #[error(transparent)]
42 BambooValidation(#[from] bamboo_rs_core_ed25519_yasmf::verify::Error),
43}
44
45#[derive(thiserror::Error, Debug)]
47pub enum LogStorageError {
48 #[error("Error occured during `LogStorage` request in storage provider: {0}")]
50 Custom(String),
51}
52
53#[derive(thiserror::Error, Debug)]
55pub enum EntryStorageError {
56 #[error("Error occured during `EntryStorage` request in storage provider: {0}")]
58 Custom(String),
59
60 #[error("Could not find expected backlink in database for entry with id: {0}")]
62 ExpectedBacklinkMissing(Hash),
63
64 #[error(
67 "The backlink hash encoded in the entry: {0} did not match the expected backlink hash"
68 )]
69 InvalidBacklinkPassed(Hash),
70
71 #[error("Could not find expected skiplink in database for entry with id: {0}")]
73 ExpectedSkiplinkMissing(Hash),
74
75 #[error("The skiplink hash encoded in the entry: {0} did not match the known hash of the skiplink target")]
78 InvalidSkiplinkPassed(Hash),
79
80 #[error("Could not find expected skiplink entry in database")]
82 ExpectedNextSkiplinkMissing,
83
84 #[error("Entry required for requested certificate pool missing at seq num: {0}")]
87 CertPoolEntryMissing(u64),
88
89 #[error(transparent)]
91 ValidationError(#[from] ValidationError),
92}
93
94#[derive(thiserror::Error, Debug)]
96pub enum OperationStorageError {
97 #[error("Error occured in OperationStore: {0}")]
99 Custom(String),
100
101 #[error("A fatal error occured in OperationStore: {0}")]
103 FatalStorageError(String),
104
105 #[error("Error occured when inserting an operation with id {0:?} into storage")]
107 InsertionError(OperationId),
108}
109
110#[derive(thiserror::Error, Debug)]
112pub enum DocumentStorageError {
113 #[error("Error occured in DocumentStore: {0}")]
115 Custom(String),
116
117 #[error("A fatal error occured in DocumentStore: {0}")]
119 FatalStorageError(String),
120
121 #[error("Error occured when inserting a document view with id {0:?} into storage")]
123 DocumentViewInsertionError(DocumentViewId),
124
125 #[error("Error occured when inserting a document with id {0:?} into storage")]
127 DocumentInsertionError(DocumentId),
128
129 #[error(transparent)]
131 OperationValidation(#[from] ValidateOperationError),
132
133 #[error(transparent)]
135 OperationStorageError(#[from] OperationStorageError),
136
137 #[error(transparent)]
139 DocumentBuilderError(#[from] DocumentBuilderError),
140}