annotation_rs_helpers/
error.rs

1use std::error::Error as StdError;
2use std::fmt::{Display, Formatter, Result};
3
4#[derive(Debug, Clone)]
5pub struct Error {
6    message: String,
7}
8impl Error {
9    pub fn new<T: Display>(message: T) -> Self {
10        Error {
11            message: message.to_string(),
12        }
13    }
14    pub fn get_message(&self) -> String {
15        self.message.clone()
16    }
17}
18
19impl StdError for Error {
20    fn source(&self) -> Option<&(dyn StdError + 'static)> {
21        None
22    }
23}
24
25impl Display for Error {
26    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
27        write!(f, "{}", self.message)
28    }
29}