1use rst_common::with_errors::thiserror::{self, Error};
2
3#[derive(Debug, Error)]
6pub enum BaseError {
7 #[error("unable to convert to json: {0}")]
8 ToJSONError(String),
9
10 #[error("validation failed: {0}")]
11 ValidateError(String),
12
13 #[error("unable to publish an event: {0}")]
14 PublishError(String),
15
16 #[error("unable to emit event: {0}")]
17 EmitError(String),
18
19 #[error("unable to handle an event: {event_name}, error: {error_msg}")]
20 HandleError {
21 event_name: String,
22 error_msg: String,
23 },
24
25 #[error("repository error: {0}")]
26 RepositoryError(String)
27}
28
29pub trait ToJSON {
32 fn to_json(&self) -> Result<String, BaseError>;
33}
34
35pub trait Validate {
37 fn validate(&self) -> Result<(), BaseError>;
38}