use std::{fmt, error, result};
use hangul::ParseSyllableError;
#[derive(Debug)]
pub enum Error {
EmptyStr,
ParseSyllable(char),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}",
match self {
Error::EmptyStr => "Empty string given to josa selector".to_owned(),
Error::ParseSyllable(c) => format!("{} is not a Hangul Syllable", c),
}
)
}
}
impl error::Error for Error {}
impl From<ParseSyllableError> for Error {
fn from(e: ParseSyllableError) -> Error {
Error::ParseSyllable(e.0)
}
}
pub type Result<T> = result::Result<T, Error>;