1use crate::{
2 config::ConfigurationError, destinations::errors::DestinationError,
3 sources::errors::SourceError,
4};
5
6#[derive(Debug)]
7pub enum MusketError {
8 Cli { message: String },
9 Configuration { message: String },
10 Destination { message: String },
11 Source { message: String },
12}
13
14impl std::error::Error for MusketError {}
15
16impl std::fmt::Display for MusketError {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 use MusketError::{Cli, Configuration, Destination, Source};
19 let output = match self {
20 Cli { message: m }
21 | Configuration { message: m }
22 | Destination { message: m }
23 | Source { message: m } => m,
24 };
25 write!(f, "{output}")
26 }
27}
28
29impl From<ConfigurationError> for MusketError {
30 fn from(e: ConfigurationError) -> Self {
31 MusketError::Configuration {
32 message: format!("{e}."),
33 }
34 }
35}
36
37impl From<DestinationError> for MusketError {
38 fn from(e: DestinationError) -> Self {
39 MusketError::Destination {
40 message: format!("{e}."),
41 }
42 }
43}
44
45impl From<SourceError> for MusketError {
46 fn from(e: SourceError) -> Self {
47 MusketError::Source {
48 message: format!("{e}."),
49 }
50 }
51}