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 InvalidTimestamp,
18}
19
20impl Display for TypeParseError {
21 fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
22 formatter.write_str(match self {
23 Self::InvalidDate => "invalid date",
24 Self::InvalidDecimal => "invalid decimal",
25 Self::InvalidDuration => "invalid duration",
26 Self::InvalidTimestamp => "invalid timestamp",
27 })
28 }
29}
30
31#[derive(Clone, Debug, Eq, Error, PartialEq)]
33pub enum SchemaContractError {
34 #[error("schema contract identity is empty")]
36 EmptyIdentity,
37
38 #[error("schema contract identity exceeds its byte limit")]
40 IdentityTooLong {
41 len: usize,
43 max: usize,
45 },
46
47 #[error("schema source key contains a non-canonical byte")]
49 InvalidSourceKey,
50
51 #[error("schema contract collection exceeds its item limit")]
53 TooManyItems {
54 kind: &'static str,
56 len: usize,
58 max: usize,
60 },
61
62 #[error("schema contract contains a duplicate source key")]
64 DuplicateSourceKey,
65
66 #[error("schema contract defines and removes the same source key")]
68 DefinitionRemovalConflict,
69
70 #[error("schema contract contains a duplicate current name")]
72 DuplicateName,
73
74 #[error("schema contract contains an unresolved local reference")]
76 InvalidLocalReference,
77
78 #[error("schema field type exceeds its inline depth bound")]
80 FieldTypeDepthExceeded,
81
82 #[error("schema contract contains an invalid enum literal reference")]
84 InvalidEnumLiteral,
85
86 #[error("schema relation source and target field types differ")]
88 RelationTypeMismatch,
89
90 #[error("schema contract removes a referenced definition")]
92 RemovedReference,
93
94 #[error("schema proposal entity routing is incomplete")]
96 MissingEntityStoreAssignment,
97
98 #[error("schema field policy is invalid")]
100 InvalidFieldPolicy,
101
102 #[error("schema field type is invalid")]
104 InvalidFieldType,
105
106 #[error("schema field default does not match its exact field type")]
108 LiteralTypeMismatch,
109
110 #[error("schema contract contains an invalid ordered reference list")]
112 InvalidReferenceList,
113
114 #[error("schema proposal literal is malformed")]
116 InvalidLiteral,
117
118 #[error("schema source check expression is malformed")]
120 InvalidExpression,
121
122 #[error("schema targeted durable-rule operation is invalid")]
124 InvalidRuleOperation,
125
126 #[error("schema targeted durable-rule target is invalid")]
128 InvalidRuleTarget,
129
130 #[error("schema entity source version must be positive")]
132 InvalidEntityVersion,
133
134 #[error("schema migration plan is invalid")]
136 InvalidMigrationPlan,
137
138 #[error("schema migration target reference is invalid")]
140 InvalidMigrationReference,
141
142 #[error("schema migration contains a duplicate source selector")]
144 DuplicateMigrationSource,
145
146 #[error("schema migration contains a duplicate target selector")]
148 DuplicateMigrationTarget,
149
150 #[error("schema migration entity versions are not contiguous")]
152 MigrationVersionGap,
153
154 #[error("schema migration transform is invalid")]
156 InvalidMigrationTransform,
157
158 #[error("schema migration program version is unsupported")]
160 UnsupportedMigrationProgramVersion {
161 found: u16,
163 supported: u16,
165 },
166
167 #[error("schema proposal contract version is unsupported")]
169 UnsupportedVersion {
170 found: u16,
172 supported: u16,
174 },
175
176 #[error("schema proposal requires an unsupported capability")]
178 UnsupportedCapability,
179
180 #[error("schema proposal is not canonically ordered")]
182 NonCanonical,
183
184 #[error("encoded schema contract exceeds its byte limit")]
186 EncodedTooLarge {
187 len: usize,
189 max: usize,
191 },
192
193 #[error("schema contract encoding failed")]
195 Encode,
196
197 #[error("schema contract decoding failed")]
199 Decode,
200}