1#[derive(Debug, Clone, PartialEq, thiserror::Error)]
3pub enum VxError {
4 #[error("{file}:{line}:{col}: {message}")]
5 Parse {
6 file: String,
7 line: usize,
8 col: usize,
9 message: String,
10 },
11 #[error("schema not found: {namespace}")]
12 SchemaNotFound { namespace: String },
13 #[error("unknown type `{type_name}` in schema `{namespace}`")]
14 UnknownType {
15 namespace: String,
16 type_name: String,
17 },
18 #[error("type mismatch: expected {expected}, got {actual}")]
19 TypeMismatch { expected: String, actual: String },
20 #[error("value overflow: {value} does not fit in {ty}")]
21 Overflow { value: String, ty: String },
22 #[error("unknown field `{field}` on type `{type_name}`")]
23 UnknownField { type_name: String, field: String },
24 #[error("unknown variant `{variant}` on type `{type_name}`")]
25 UnknownVariant { type_name: String, variant: String },
26 #[error("missing @schema directive")]
27 MissingSchemaDirective,
28 #[error("validation: {message}")]
29 Validation { message: String },
30}
31
32#[derive(Debug, Clone, PartialEq, thiserror::Error)]
34pub enum VxbError {
35 #[error("not a valid Vexil binary file (bad magic bytes)")]
36 BadMagic,
37 #[error("unsupported format version {version} (max supported: {max_supported})")]
38 UnsupportedVersion { version: u8, max_supported: u8 },
39 #[error("schema hash mismatch: file={file_hash}, loaded={loaded_hash}")]
40 SchemaHashMismatch {
41 file_hash: String,
42 loaded_hash: String,
43 },
44 #[error("decompression failed: {message}")]
45 DecompressionFailed { message: String },
46 #[error("I/O error: {message}")]
47 Io { message: String },
48 #[error("encode error: {0}")]
49 Encode(#[from] vexil_runtime::EncodeError),
50 #[error("decode error: {0}")]
51 Decode(#[from] vexil_runtime::DecodeError),
52}
53
54#[derive(Debug, Clone, PartialEq, thiserror::Error)]
56pub enum StoreEncodeError {
57 #[error("type mismatch: expected {expected}, got {actual}")]
58 TypeMismatch { expected: String, actual: String },
59 #[error("unknown type")]
60 UnknownTypeId,
61 #[error("unknown variant `{variant}` on type `{type_name}`")]
62 UnknownVariant { type_name: String, variant: String },
63 #[error("unknown field `{field}` on type `{type_name}`")]
64 UnknownField { type_name: String, field: String },
65 #[error("value {value} does not fit in {bits} bits")]
66 Overflow { value: String, bits: u8 },
67 #[error("bitpack error: {0}")]
68 Bitpack(#[from] vexil_runtime::EncodeError),
69 #[error("type `{type_name}` not found in schema")]
70 TypeNotFound { type_name: String },
71 #[error("recursion depth exceeded")]
72 RecursionLimit,
73}
74
75#[derive(Debug, Clone, PartialEq, thiserror::Error)]
77pub enum StoreDecodeError {
78 #[error("type mismatch at {context}: expected {expected}")]
79 TypeMismatch { context: String, expected: String },
80 #[error("unknown type")]
81 UnknownTypeId,
82 #[error("unknown enum variant ordinal {ordinal} on type `{type_name}`")]
83 UnknownVariant { type_name: String, ordinal: u64 },
84 #[error("unknown union discriminant {discriminant} on type `{type_name}`")]
85 UnknownUnionDiscriminant {
86 type_name: String,
87 discriminant: u64,
88 },
89 #[error("bitpack error: {0}")]
90 Bitpack(#[from] vexil_runtime::DecodeError),
91 #[error("type `{type_name}` not found in schema")]
92 TypeNotFound { type_name: String },
93 #[error("recursion depth exceeded")]
94 RecursionLimit,
95}