big_int/
error.rs

1//! big int errors.
2
3use thiserror::Error;
4
5/// Represents an error with regards to a big int operation.
6#[derive(Error, Debug, PartialEq, Eq)]
7pub enum BigIntError {
8    #[error("base too large: number has {0} digits, alphabet can only represent {1} digits")]
9    BaseTooHigh(usize, usize),
10    #[error("parsing failed: {0}")]
11    ParseFailed(ParseError),
12    #[error("division by zero")]
13    DivisionByZero,
14    #[error("exponentiation with negative exponent")]
15    NegativeExponentiation,
16    #[error("logarithm of non positive number")]
17    NonPositiveLogarithm,
18    #[error("logarithm with base < 2")]
19    LogOfSmallBase,
20    #[error("nth root of negative number")]
21    NegativeRoot,
22    #[error("nth root with root < 2")]
23    SmallRoot,
24}
25
26/// Represents an error with regards to a big int parsing operation.
27#[derive(Error, Debug, PartialEq, Eq)]
28pub enum ParseError {
29    #[error("unrecognized character: {0:?}")]
30    UnrecognizedCharacter(char),
31    #[error("not enough characters")]
32    NotEnoughCharacters,
33    #[error("char {0:?} is {1}; too large to be represented in base {2}")]
34    DigitTooLarge(char, usize, usize),
35}