protobuf_mapper/
result.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Error {
5 #[error("JSON error: {0}")]
6 Json(#[from] serde_json::Error),
7 #[error("Could not convert json value from type_url: {type_url}")]
8 JsonTypeUrlUnknown { type_url: String },
9 #[error("Could not unpack a non-optional value from null")]
10 ValueNotPresent,
11 #[error("Could not unpack field '{field_name}' from null")]
12 FieldValueNotPresent { field_name: &'static str },
13 #[error("JSON value nested too deeply")]
14 JsonValueNestedTooDeeply,
15 #[error("List element {index}: {source}")]
16 ListElement { source: Box<Error>, index: usize },
17 #[error("Map entry: {}", source)]
18 MapEntry { source: Box<Error> },
19 #[error("Parse decimal error: {0}")]
20 ParseBigDecimal(#[from] bigdecimal::ParseBigDecimalError),
21 #[error("Parse duration error: {message}")]
22 ParseDuration { message: String },
23 #[error(
24 "Enum discriminant is not found: enum type = {}, discriminant = {}",
25 enum_name,
26 discriminant
27 )]
28 EnumDiscriminantNotFound {
29 enum_name: &'static str,
30 discriminant: i32,
31 },
32}
33
34pub type Result<T, E = Error> = std::result::Result<T, E>;