tightbeam/builder/
error.rs1#[cfg(not(feature = "std"))]
2extern crate alloc;
3
4use crate::{Errorizable, Version};
5
6#[derive(Errorizable, Debug, Clone, PartialEq, Eq)]
8pub enum MetadataError {
9 #[error("Missing required field: id")]
11 MissingId,
12
13 #[error("Missing required field: order")]
15 MissingTimestamp,
16
17 #[error("Missing required field: hash (required for V2)")]
19 MissingHash,
20
21 #[error("Missing required field: encryption (required for V1+)")]
23 MissingEncryption,
24
25 #[error("Field '{field}' is not supported in protocol version {version:?}")]
27 UnsupportedField { field: &'static str, version: Version },
28}
29
30#[derive(Errorizable, Debug)]
32pub enum BuildError {
33 #[error("Invalid metadata: {0}")]
35 #[from]
36 #[source]
37 InvalidMetadata(MetadataError),
38
39 #[error("Matrix error: {0}")]
41 #[from]
42 #[source]
43 MatrixError(crate::matrix::MatrixError),
44
45 #[error("Serialization error: {0}")]
47 #[from]
48 #[source]
49 Serialization(der::Error),
50
51 #[cfg(feature = "aead")]
53 #[error("Encryption error: {0}")]
54 #[from]
55 #[source]
56 Encryption(aead::Error),
57
58 #[cfg(feature = "signature")]
60 #[error("Signature error: {0}")]
61 #[from]
62 #[source]
63 Signature(signature::Error),
64
65 #[cfg(feature = "compress")]
67 #[error("Compression error: {0}")]
68 Compression(crate::error::CompressionError),
69
70 #[cfg(feature = "random")]
72 #[error("Random number generation error: {0}")]
73 #[from]
74 #[source]
75 Random(rand_core::Error),
76
77 #[error("Missing message body")]
79 MissingMessage,
80}