rust_music_theory/note/
errors.rs

1use std::error;
2use std::fmt;
3
4/// An error caused when parsing a note.
5#[derive(Debug, Clone)]
6pub enum NoteError {
7    InvalidPitch,
8}
9
10impl fmt::Display for NoteError {
11    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12        write!(f, "Invalid Pitch Class!")
13    }
14}
15
16impl error::Error for NoteError {}
17
18impl From<regex::Error> for NoteError {
19    fn from(e: regex::Error) -> Self {
20        match e {
21            _ => NoteError::InvalidPitch,
22        }
23    }
24}