|
1 |
| -use snafu::Snafu; |
| 1 | +use thiserror::Error; |
2 | 2 |
|
3 | 3 | /// Represents an error during serialization/deserialization process
|
4 |
| -#[derive(Debug, Snafu)] |
| 4 | +#[derive(Debug, Error)] |
5 | 5 | pub enum Error {
|
6 |
| - #[snafu(display("Wrong encoding"))] |
| 6 | + #[error("Wrong encoding")] |
7 | 7 | WrongEncoding {},
|
8 |
| - #[snafu(display("{}", source))] |
9 |
| - #[snafu(context(false))] |
| 8 | + #[error(transparent)] |
10 | 9 | UnknownSpecVersion {
|
| 10 | + #[from] |
11 | 11 | source: crate::event::UnknownSpecVersion,
|
12 | 12 | },
|
13 |
| - #[snafu(display("Unknown attribute in this spec version: {}", name))] |
| 13 | + #[error("Unknown attribute in this spec version: {name}")] |
14 | 14 | UnknownAttribute { name: String },
|
15 |
| - #[snafu(display("Error while building the final event: {}", source))] |
16 |
| - #[snafu(context(false))] |
| 15 | + #[error("Error while building the final event: {source}")] |
17 | 16 | EventBuilderError {
|
| 17 | + #[from] |
18 | 18 | source: crate::event::EventBuilderError,
|
19 | 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))] |
| 20 | + #[error("Error while parsing a time string: {source}")] |
| 21 | + ParseTimeError { |
| 22 | + #[from] |
| 23 | + source: chrono::ParseError, |
| 24 | + }, |
| 25 | + #[error("Error while parsing a url: {source}")] |
| 26 | + ParseUrlError { |
| 27 | + #[from] |
| 28 | + source: url::ParseError, |
| 29 | + }, |
| 30 | + #[error("Error while decoding base64: {source}")] |
| 31 | + Base64DecodingError { |
| 32 | + #[from] |
| 33 | + source: base64::DecodeError, |
| 34 | + }, |
| 35 | + #[error("Error while serializing/deserializing to json: {source}")] |
| 36 | + SerdeJsonError { |
| 37 | + #[from] |
| 38 | + source: serde_json::Error, |
| 39 | + }, |
| 40 | + #[error("IO Error: {source}")] |
| 41 | + IOError { |
| 42 | + #[from] |
| 43 | + source: std::io::Error, |
| 44 | + }, |
| 45 | + #[error("Other error: {}", source)] |
36 | 46 | Other {
|
37 | 47 | source: Box<dyn std::error::Error + Send + Sync>,
|
38 | 48 | },
|
|
0 commit comments