1use std::error::Error as StdError;
2use std::fmt;
3
4pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct Error {
8 message: String,
9}
10
11impl Error {
12 pub fn new(message: impl Into<String>) -> Self {
13 Self {
14 message: message.into(),
15 }
16 }
17
18 pub fn message(&self) -> &str {
19 &self.message
20 }
21}
22
23impl fmt::Display for Error {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 f.write_str(self.message())
26 }
27}
28
29impl StdError for Error {}