1use crate::document::DocumentId;
4use crate::entry::error::DecodeEntryError;
5use crate::identity::PublicKey;
6use crate::operation::error::ValidateOperationError;
7use crate::operation::OperationId;
8use crate::schema::SchemaId;
9use crate::storage_provider::error::{EntryStorageError, LogStorageError, OperationStorageError};
10
11#[derive(thiserror::Error, Debug)]
13pub enum ValidationError {
14 #[error("Entry's claimed seq num of {0} does not match expected seq num of {1} for given public key and log")]
16 SeqNumDoesNotMatch(u64, u64),
17
18 #[error("Expected skiplink entry not found in store: public key {0}, log id {1}, seq num {2}")]
20 ExpectedSkiplinkNotFound(String, u64, u64),
21
22 #[error(
24 "Entry's claimed log id of {0} does not match existing log id of {1} for given public key and document id"
25 )]
26 LogIdDoesNotMatchExisting(u64, u64),
27
28 #[error("Expected log not found in store for: public key {0}, document id {1}")]
30 ExpectedDocumentLogNotFound(PublicKey, DocumentId),
31
32 #[error("Entry's claimed log id of {0} is already in use for given public key")]
34 LogIdDuplicate(u64),
35
36 #[error("Entry with seq num 1 can not have skiplink")]
38 FirstEntryWithSkiplink,
39
40 #[error("Operation {0} claims incorrect schema {1} for document with schema {2}")]
42 InvalidClaimedSchema(OperationId, SchemaId, SchemaId),
43
44 #[error("Document is deleted")]
46 DocumentDeleted,
47
48 #[error("Max sequence number reached")]
50 MaxSeqNum,
51
52 #[error("Max log id reached")]
54 MaxLogId,
55
56 #[error("Previous operation {0} not found in store")]
58 PreviousOperationNotFound(OperationId),
59
60 #[error("Operations in passed document view id originate from different documents")]
62 InvalidDocumentViewId,
63
64 #[error(transparent)]
66 LogStoreError(#[from] LogStorageError),
67
68 #[error(transparent)]
70 EntryStoreError(#[from] EntryStorageError),
71
72 #[error(transparent)]
74 OperationStoreError(#[from] OperationStorageError),
75}
76
77#[derive(thiserror::Error, Debug)]
79pub enum DomainError {
80 #[error("Max sequence number reached for public key {0} log {1}")]
82 MaxSeqNumReached(String, u64),
83
84 #[error("You are trying to update or delete a document which has been deleted")]
86 DeletedDocument,
87
88 #[error("Expected log id {0} not found when calculating next args")]
90 ExpectedLogIdNotFound(u64),
91
92 #[error(transparent)]
94 ValidationError(#[from] ValidationError),
95
96 #[error(transparent)]
98 LogStoreError(#[from] LogStorageError),
99
100 #[error(transparent)]
102 EntryStoreError(#[from] EntryStorageError),
103
104 #[error(transparent)]
106 OperationStoreError(#[from] OperationStorageError),
107
108 #[error(transparent)]
110 DecodeEntryError(#[from] DecodeEntryError),
111
112 #[error(transparent)]
114 ValidateOperationError(#[from] ValidateOperationError),
115}