Skip to main content

boomie/
error.rs

1use std::fmt;
2
3impl std::error::Error for SynthError {}
4
5#[derive(Debug, Clone)]
6pub enum SynthError {
7    ParseError(String),
8    FileError(String),
9    AudioError(String),
10    InvalidInstrument(String),
11}
12
13impl fmt::Display for SynthError { // TODO, expand
14    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15        match self {
16            SynthError::ParseError(msg) => write!(f, "Parsing Error: {}", msg),
17            SynthError::FileError(msg) => write!(f, "File Error: {}", msg),
18            SynthError::AudioError(msg) => write!(f, "Audio Error: {}", msg),
19            SynthError::InvalidInstrument(msg) => write!(f, "Invalid Instrument Error: {}", msg),
20        }
21    }
22}