1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::num::ParseIntError;
use thiserror::Error;
#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ParseEnumError;
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum CompileError {
#[error("invalid gurgle syntax: {0}")]
InvalidSyntax(String),
#[error("command contains invalid number")]
ParseNumberError(#[from] ParseIntError),
#[error("Roll times or slides can't be negative")]
DiceRollOrSidedNegative,
#[error("dice roll times limit exceeded")]
DiceRollTimesLimitExceeded,
#[error("dice sides count limit exceeded")]
DiceSidedCountLimitExceeded,
#[error("items count limit exceeded")]
ItemCountLimitExceeded,
#[error("number item out of range")]
NumberItemOutOfRange,
}
impl<R: pest::RuleType> From<pest::error::Error<R>> for CompileError {
fn from(err: pest::error::Error<R>) -> Self {
Self::InvalidSyntax(format!("{}", err))
}
}