1use crate::dice::DiceRoll;
4use thiserror::Error;
5
6#[derive(Debug, Clone, Error)]
8pub enum RollError {
9 #[error("Adding integers {0} and {1} would overflow")]
12 IntegerOverFlow(u32, u32),
13}
14
15#[derive(Debug, Clone, Error)]
17pub enum Error {
18 #[error(
20 "'{0}' is an invalid number of sides for a Dice (must be at least {})",
21 DiceRoll::MINIMUM_SIDES
22 )]
23 InvalidSides(u32),
24
25 #[error(
27 "'{0}' is an invalid number of rolls for a Dice (must be at least {})",
28 DiceRoll::MINIMUM_ROLLS
29 )]
30 InvalidRolls(u32),
31
32 #[error("Sides were not captured from the provided expression '{0}'.")]
34 FailedToParseSides(String),
35
36 #[error("Rolls were not captured from the provided expression '{0}'.")]
38 FailedToParseRolls(String),
39
40 #[error("'{0}' could not be parsed into a pair of rolls and sides.")]
42 InvalidExpression(String),
43}