p2panda_rs/operation/
error.rs1use thiserror::Error;
6
7#[derive(Error, Debug)]
9pub enum OperationBuilderError {
10 #[error(transparent)]
12 ValidateOperationError(#[from] ValidateOperationError),
13}
14
15#[derive(Error, Debug)]
17pub enum EncodeOperationError {
18 #[error("cbor encoder failed {0}")]
20 EncoderIOFailed(String),
21
22 #[error("cbor encoder failed serializing value {0}")]
24 EncoderFailed(String),
25}
26
27#[derive(Error, Debug)]
29pub enum DecodeOperationError {
30 #[error("cbor decoder failed {0}")]
32 DecoderIOFailed(String),
33
34 #[error("invalid cbor encoding at byte {0}")]
36 InvalidCBOREncoding(usize),
37
38 #[error("{0}")]
40 InvalidEncoding(String),
41
42 #[error("cbor decoder exceeded recursion limit")]
44 RecursionLimitExceeded,
45}
46
47#[derive(Error, Debug)]
49pub enum ValidateOperationError {
50 #[error("operation schema id not matching with given schema: {0}, expected: {1}")]
52 SchemaNotMatching(String, String),
53
54 #[error("expected 'fields' in CREATE or UPDATE operation")]
56 ExpectedFields,
57
58 #[error("unexpected 'fields' in DELETE operation")]
60 UnexpectedFields,
61
62 #[error("expected 'previous' in UPDATE or DELETE operation")]
64 ExpectedPreviousOperations,
65
66 #[error("unexpected 'previous' in CREATE operation")]
68 UnexpectedPreviousOperations,
69
70 #[error(transparent)]
72 SchemaValidation(#[from] crate::schema::validate::error::ValidationError),
73
74 #[error(transparent)]
76 ValidateEntryError(#[from] crate::entry::error::ValidateEntryError),
77}
78
79#[derive(Error, Debug)]
81pub enum FieldsError {
82 #[error("field '{0}' already exists")]
84 FieldDuplicate(String),
85
86 #[error("field does not exist")]
88 UnknownField,
89}
90
91#[derive(Error, Debug)]
93pub enum OperationIdError {
94 #[error(transparent)]
96 HashError(#[from] crate::hash::error::HashError),
97}
98
99#[derive(Error, Debug)]
101pub enum PlainValueError {
102 #[error("attempted to parse non-utf8 bytes into string")]
104 BytesNotUtf8,
105
106 #[error(transparent)]
108 IntError(#[from] std::num::TryFromIntError),
109
110 #[error("data did not match any variant of untagged enum PlainValue")]
112 UnsupportedValue,
113}
114
115#[derive(Error, Debug)]
117pub enum RelationError {
118 #[error(transparent)]
120 DocumentIdError(#[from] crate::document::error::DocumentIdError),
121}
122
123#[derive(Error, Debug)]
125pub enum PinnedRelationError {
126 #[error(transparent)]
128 DocumentViewIdError(#[from] crate::document::error::DocumentViewIdError),
129}
130
131#[derive(Error, Debug)]
133pub enum RelationListError {
134 #[error(transparent)]
136 DocumentIdError(#[from] crate::document::error::DocumentIdError),
137}
138
139#[derive(Error, Debug)]
141pub enum PinnedRelationListError {
142 #[error(transparent)]
144 DocumentViewIdError(#[from] crate::document::error::DocumentViewIdError),
145}
146
147#[derive(Error, Debug)]
149#[allow(missing_copy_implementations)]
150pub enum OperationActionError {
151 #[error("unknown operation action {0}")]
153 UnknownAction(u64),
154}