forked from cloudevents/sdk-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.rs
More file actions
53 lines (51 loc) · 1.47 KB
/
error.rs
File metadata and controls
53 lines (51 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use thiserror::Error;
/// Represents an error during serialization/deserialization process
#[derive(Debug, Error)]
pub enum Error {
#[error("Wrong encoding")]
WrongEncoding {},
#[error(transparent)]
UnknownSpecVersion {
#[from]
source: crate::event::UnknownSpecVersion,
},
#[error("Unknown attribute in this spec version: {name}")]
UnknownAttribute { name: String },
#[error("Error while building the final event: {source}")]
EventBuilderError {
#[from]
source: crate::event::EventBuilderError,
},
#[error("Error while parsing a time string: {source}")]
ParseTimeError {
#[from]
source: chrono::ParseError,
},
#[error("Error while parsing a url: {source}")]
ParseUrlError {
#[from]
source: url::ParseError,
},
#[error("Error while decoding base64: {source}")]
Base64DecodingError {
#[from]
source: base64::DecodeError,
},
#[error("Error while serializing/deserializing to json: {source}")]
SerdeJsonError {
#[from]
source: serde_json::Error,
},
#[error("IO Error: {source}")]
IOError {
#[from]
source: std::io::Error,
},
#[error("Other error: {}", source)]
Other {
#[from]
source: Box<dyn std::error::Error + Send + Sync>,
},
}
/// Result type alias for return values during serialization/deserialization process
pub type Result<T> = std::result::Result<T, Error>;