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
use thiserror::Error;

/// Errors related to a recorded event
#[derive(Error, Debug)]
pub enum RecordedEventError {
    #[error("Unable to deserialize the recorded event")]
    DeserializeError(serde_json::Error),
}

/// Errors related to a unsaved event
#[derive(Error, Debug)]
pub enum UnsavedEventError {
    #[error("Unable to serialize the event")]
    SerializeError(serde_json::Error),
}

impl From<serde_json::Error> for UnsavedEventError {
    fn from(e: serde_json::Error) -> Self {
        Self::SerializeError(e)
    }
}
impl From<serde_json::Error> for RecordedEventError {
    fn from(e: serde_json::Error) -> Self {
        Self::DeserializeError(e)
    }
}