Files
artcraft-services/src/synthesis/error.rs
T
Brandon Thomas 0ea02db27f Refactor of synthesis-related code
- refactor and modularize code into "sentence synth" and "word synth"
- change synth params in code and UI
- change error types, better error handling
2016-10-30 02:25:52 -04:00

62 lines
1.2 KiB
Rust

// Copyright (c) 2016 Brandon Thomas <bt@brand.io, echelon@gmail.com>
use hound::Error as HoundError;
use std::convert::From;
use std::error::Error;
use std::fmt;
use std::io;
/// Error in synthesizing audio.
#[derive(Debug)]
pub enum SynthesisError {
ArpabetEntryDne,
/// Bad user input.
BadInput { description: &'static str },
/// Cannot load an expected audio file, eg. "blank.wav".
CannotLoadAudioFile,
CannotSynthesizeWord,
/// Wraps a Hound audio library error.
HoundError { cause: HoundError },
/// Wraps an IoError.
IoError { cause: io::Error },
/// Could not obtain a lock.
LockError,
MonophoneDne,
WordSampleDne,
}
impl Error for SynthesisError {
fn description(&self) -> &str {
"Synthesis Error" // TODO
}
/*fn cause(&self) -> Option<&Error> {
Some(&self)
}*/
}
impl fmt::Display for SynthesisError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Synthesis Error")
}
}
impl From<io::Error> for SynthesisError {
fn from(error: io::Error) -> SynthesisError {
SynthesisError::IoError { cause: error }
}
}
impl From<HoundError> for SynthesisError {
fn from(error: HoundError) -> SynthesisError {
SynthesisError::HoundError { cause: error }
}
}