nettext/src/enc/error.rs
2022-11-18 18:59:06 +01:00

24 lines
839 B
Rust

use std::fmt;
/// An error that happenned when creating a nettext encoder term
#[derive(Debug)]
pub enum Error {
InvalidCharacter(u8),
InvalidRaw,
NotADictionnary,
DuplicateKey(String),
ListInList,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::InvalidCharacter(c) => write!(f, "Invalid character '{}'", *c as char),
Error::InvalidRaw => write!(f, "Invalid RAW nettext litteral"),
Error::NotADictionnary => write!(f, "Tried to insert into a term that isn't a dictionnary"),
Error::DuplicateKey(s) => write!(f, "Duplicate dict key: {}", s),
Error::ListInList => write!(f, "Refusing to build nested lists with list(), use either list_flatten() or list_nested()"),
}
}
}