More examples, better defaults
grammar_separated is grammar but with all functions exposed
This commit is contained in:
30
grammar_separated/src/custom_error.rs
Normal file
30
grammar_separated/src/custom_error.rs
Normal file
@ -0,0 +1,30 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
pub enum UserErrorTypes {
|
||||
NumberTooBigUsize,
|
||||
NumberTooBigi64,
|
||||
}
|
||||
|
||||
impl Display for UserErrorTypes {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
| Self::NumberTooBigUsize => write!(
|
||||
f,
|
||||
"Specified number is too big (greater than {})",
|
||||
usize::MAX
|
||||
),
|
||||
| Self::NumberTooBigi64 => write!(
|
||||
f,
|
||||
"Specified number is too big (lesser than {} or \
|
||||
greater than {})",
|
||||
i64::MIN,
|
||||
i64::MAX
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UserError {
|
||||
pub token: (usize, String, usize),
|
||||
pub error: UserErrorTypes,
|
||||
}
|
||||
Reference in New Issue
Block a user