1use thiserror::Error;
4use waratah_storage::StorageError;
5
6#[derive(Debug, Error)]
8pub enum ProtoError {
9 #[error("missing required field: {0}")]
11 MissingField(&'static str),
12
13 #[error("invalid encoded term: {0}")]
15 Term(#[from] StorageError),
16
17 #[error("{0} trailing byte(s) after encoded term")]
19 TrailingTermBytes(usize),
20
21 #[error("StrHash must be 16 bytes, got {0}")]
23 StrHashLength(usize),
24
25 #[error("enum field {0} is unspecified")]
27 UnspecifiedEnum(&'static str),
28
29 #[error("enum field {0} has an unknown value {1}")]
31 UnknownEnum(&'static str, i32),
32
33 #[error("field {0} must carry a non-empty encoded term")]
35 EmptyTerm(&'static str),
36
37 #[error("slot comparisons cannot target the graph slot")]
39 GraphComparisonSlot,
40
41 #[error("omitted_slots has bits outside the four quad slots: {0:#x}")]
43 SlotMask(u32),
44}
45
46impl From<ProtoError> for tonic::Status {
47 fn from(error: ProtoError) -> Self {
48 Self::invalid_argument(error.to_string())
49 }
50}