cloudevents/message/
error.rs1use snafu::Snafu;
2
3#[derive(Debug, Snafu)]
5pub enum Error {
6 #[snafu(display("Wrong encoding"))]
7 WrongEncoding {},
8 #[snafu(display("{}", source))]
9 #[snafu(context(false))]
10 UnknownSpecVersion {
11 source: crate::event::UnknownSpecVersion,
12 },
13 #[snafu(display("Unknown attribute in this spec version: {}", name))]
14 UnknownAttribute { name: String },
15 #[snafu(display("Error while building the final event: {}", source))]
16 #[snafu(context(false))]
17 EventBuilderError {
18 source: crate::event::EventBuilderError,
19 },
20 #[snafu(display("Error while parsing a time string: {}", source))]
21 #[snafu(context(false))]
22 ParseTimeError { source: chrono::ParseError },
23 #[snafu(display("Error while parsing a url: {}", source))]
24 #[snafu(context(false))]
25 ParseUrlError { source: url::ParseError },
26 #[snafu(display("Error while decoding base64: {}", source))]
27 #[snafu(context(false))]
28 Base64DecodingError { source: base64::DecodeError },
29 #[snafu(display("Error while serializing/deserializing to json: {}", source))]
30 #[snafu(context(false))]
31 SerdeJsonError { source: serde_json::Error },
32 #[snafu(display("IO Error: {}", source))]
33 #[snafu(context(false))]
34 IOError { source: std::io::Error },
35 #[snafu(display("Other error: {}", source))]
36 Other {
37 source: Box<dyn std::error::Error + Send + Sync>,
38 },
39}
40
41pub type Result<T> = std::result::Result<T, Error>;