Skip to main content

classy_sync/
errors.rs

1// Error handling will be looked at more
2use std::fmt;
3
4pub type Error = Box<dyn std::error::Error>;
5
6#[derive(Debug)]
7pub struct SyncError {
8    message: String,
9}
10
11impl SyncError {
12    pub fn new<T: ToString>(message: T) -> Box<SyncError> {
13        Box::new(SyncError {
14            message: message.to_string(),
15        })
16    }
17}
18
19impl std::error::Error for SyncError {}
20
21impl fmt::Display for SyncError {
22    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23        write!(f, "Error: {}", self.message)
24    }
25}