1#[cfg(feature = "alloc")]
8use alloc::{boxed::Box, string::String};
9
10pub type Result<T = ()> = core::result::Result<T, Error>;
12
13#[derive(Debug, thiserror::Error)]
15pub enum Error {
16 #[error("Invalid Chord")]
17 InvalidChord,
18 #[cfg(feature = "alloc")]
19 #[error("Invalid Intervals: {0}")]
20 InvalidIntervals(String),
21 #[error("Invalid Note")]
22 InvalidNote,
23 #[cfg(feature = "anyhow")]
24 #[error(transparent)]
25 AnyError(#[from] anyhow::Error),
26 #[error(transparent)]
27 FmtError(#[from] core::fmt::Error),
28 #[cfg(feature = "alloc")]
29 #[error(transparent)]
30 BoxError(#[from] Box<dyn core::error::Error + Send + Sync>),
31 #[cfg(feature = "std")]
32 #[error(transparent)]
33 IOError(#[from] std::io::Error),
34 #[error(transparent)]
35 #[cfg(feature = "serde_json")]
36 JsonError(#[from] serde_json::Error),
37 #[cfg(feature = "alloc")]
38 #[error("Unknown Error: {0}")]
39 Unknown(String),
40}
41
42#[cfg(feature = "alloc")]
43impl From<&str> for Error {
44 fn from(s: &str) -> Self {
45 Error::Unknown(String::from(s))
46 }
47}
48
49#[cfg(feature = "alloc")]
50impl From<String> for Error {
51 fn from(s: String) -> Self {
52 Error::Unknown(s)
53 }
54}