1use std::fmt::{self, Display, Formatter};
4
5use thiserror::Error;
6
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
9pub enum TypeParseError {
10 InvalidDate,
12 InvalidDecimal,
14 InvalidDuration,
16 InvalidIntBig,
18 InvalidTimestamp,
20}
21
22impl Display for TypeParseError {
23 fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
24 formatter.write_str(match self {
25 Self::InvalidDate => "invalid date",
26 Self::InvalidDecimal => "invalid decimal",
27 Self::InvalidDuration => "invalid duration",
28 Self::InvalidIntBig => "invalid signed big integer",
29 Self::InvalidTimestamp => "invalid timestamp",
30 })
31 }
32}
33
34#[derive(Clone, Debug, Eq, Error, PartialEq)]
36pub enum SchemaContractError {
37 #[error("schema contract identity is empty")]
39 EmptyIdentity,
40
41 #[error("schema contract identity exceeds its byte limit")]
43 IdentityTooLong {
44 len: usize,
46 max: usize,
48 },
49
50 #[error("schema source key contains a non-canonical byte")]
52 InvalidSourceKey,
53
54 #[error("schema contract collection exceeds its item limit")]
56 TooManyItems {
57 kind: &'static str,
59 len: usize,
61 max: usize,
63 },
64
65 #[error("schema contract contains a duplicate source key")]
67 DuplicateSourceKey,
68
69 #[error("schema contract defines and removes the same source key")]
71 DefinitionRemovalConflict,
72
73 #[error("schema contract contains a duplicate current name")]
75 DuplicateName,
76
77 #[error("schema contract contains an unresolved local reference")]
79 InvalidLocalReference,
80
81 #[error("schema field type exceeds its inline depth bound")]
83 FieldTypeDepthExceeded,
84
85 #[error("schema contract contains an invalid enum literal reference")]
87 InvalidEnumLiteral,
88
89 #[error("schema relation source and target field types differ")]
91 RelationTypeMismatch,
92
93 #[error("schema contract removes a referenced definition")]
95 RemovedReference,
96
97 #[error("schema proposal entity routing is incomplete")]
99 MissingEntityStoreAssignment,
100
101 #[error("schema field policy is invalid")]
103 InvalidFieldPolicy,
104
105 #[error("schema field type is invalid")]
107 InvalidFieldType,
108
109 #[error("schema field default does not match its exact field type")]
111 LiteralTypeMismatch,
112
113 #[error("schema contract contains an invalid ordered reference list")]
115 InvalidReferenceList,
116
117 #[error("schema proposal literal is malformed")]
119 InvalidLiteral,
120
121 #[error("schema source check expression is malformed")]
123 InvalidExpression,
124
125 #[error("schema targeted durable-rule operation is invalid")]
127 InvalidRuleOperation,
128
129 #[error("schema targeted durable-rule target is invalid")]
131 InvalidRuleTarget,
132
133 #[error("schema entity source version must be positive")]
135 InvalidEntityVersion,
136
137 #[error("schema migration plan is invalid")]
139 InvalidMigrationPlan,
140
141 #[error("schema migration target reference is invalid")]
143 InvalidMigrationReference,
144
145 #[error("schema migration contains a duplicate source selector")]
147 DuplicateMigrationSource,
148
149 #[error("schema migration contains a duplicate target selector")]
151 DuplicateMigrationTarget,
152
153 #[error("schema migration entity versions are not contiguous")]
155 MigrationVersionGap,
156
157 #[error("schema migration transform is invalid")]
159 InvalidMigrationTransform,
160
161 #[error("schema migration program version is unsupported")]
163 UnsupportedMigrationProgramVersion {
164 found: u16,
166 supported: u16,
168 },
169
170 #[error("schema proposal contract version is unsupported")]
172 UnsupportedVersion {
173 found: u16,
175 supported: u16,
177 },
178
179 #[error("schema proposal requires an unsupported capability")]
181 UnsupportedCapability,
182
183 #[error("schema proposal is not canonically ordered")]
185 NonCanonical,
186
187 #[error("encoded schema contract exceeds its byte limit")]
189 EncodedTooLarge {
190 len: usize,
192 max: usize,
194 },
195
196 #[error("schema contract encoding failed")]
198 Encode,
199
200 #[error("schema contract decoding failed")]
202 Decode,
203}