1pub(crate) type Result<T = ()> = core::result::Result<T, MusicError>;
8
9#[derive(Debug, thiserror::Error)]
10pub enum MusicError {
11 #[error("Invalid Chord")]
12 InvalidChord,
13 #[error("Invalid Intervals: {0}")]
14 InvalidIntervals(String),
15 #[error("Invalid Note")]
16 InvalidNote,
17 #[error("Invalid Triad Class")]
18 InvalidTriadClass,
19 #[error(transparent)]
20 Other(#[from] anyhow::Error),
21 #[error("Unknown Error: {0}")]
22 Unknown(String),
23}
24
25impl From<&str> for MusicError {
26 fn from(s: &str) -> Self {
27 MusicError::Unknown(s.to_string())
28 }
29}
30
31impl From<String> for MusicError {
32 fn from(s: String) -> Self {
33 MusicError::Unknown(s)
34 }
35}
36
37impl From<Box<dyn std::error::Error>> for MusicError {
38 fn from(e: Box<dyn std::error::Error>) -> Self {
39 MusicError::Unknown(e.to_string())
40 }
41}