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
use std::error::Error as StdError;
use std::fmt::{self, Display};
#[derive(Debug)]
pub struct Error(String);
impl Error {
pub fn new(detail: &str) -> Self {
Self(detail.to_owned())
}
}
impl StdError for Error {}
impl Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, fmt)
}
}
#[derive(Debug)]
pub struct SerializationError(String);
impl SerializationError {
pub fn new(detail: &str) -> Self {
Self(detail.to_owned())
}
}
impl StdError for SerializationError {}
impl Display for SerializationError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, fmt)
}
}