use std::num::ParseIntError;
use thiserror::Error;
use crate::key_repr::parsing::parser::tokenizer::Token;
#[derive(Error, Debug)]
pub enum TrieReplace<K> {
#[error("The Trie has no node with the key: {0}")]
NoNodeWithKey(Vec<K>),
}
#[derive(Error, Debug)]
pub enum TrieInsert<K, V> {
#[error("The key ({0:?}) is already used.")]
KeyAlreadySet(Vec<K>),
#[error(
"The part of the key ({child_key:?}) is already used to refer to a child (with value: {child_value:#?})."
)]
KeyIncludesChild { child_key: Vec<K>, child_value: V },
}
#[derive(Error, Debug)]
pub enum KeyParse {
#[error("The string ('{0}') was not Recognized.")]
NotRecognized(String),
#[error("The input stream ended, before parsing finished")]
UnexpectedEnd,
#[error("The number associate with the F key ('{0}') can't be parsed as u8.")]
CantParseFNumber(#[from] ParseIntError),
#[error("The String ('{0}') is not a correct special key name.")]
UnexpectedSpecialKey(String),
#[error("Expected to find token: {expected}, but found: {found}")]
ExpectedButFound { expected: Token, found: Token },
#[error("Expected to find a char token, but found: {0}")]
ExpectedCharFound(Token),
#[error("Found unknown long modifer: {0}")]
UnknownLongMod(String),
#[error("Found unknown short modifer: {0}")]
UnknownShortMod(char),
#[error("The modifer ('{0}') was set more than once.")]
ModifierAlreadySet(String),
#[error("The string ('{0}') should only contain one key, but contains more.")]
TooManyKeys(String),
}
#[cfg(feature = "crossterm")]
#[derive(Error, Debug)]
pub enum KeyFromCrossterm {
#[error("Can not parse non Key event to a Key code: ('{0:?}')")]
OnlyKey(crossterm::event::Event),
}