Coverage Report

Created: 2025-08-13 21:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/home/a220/proj/radnelac/src/common/error.rs
Line
Count
Source
1
// This Source Code Form is subject to the terms of the Mozilla Public
2
// License, v. 2.0. If a copy of the MPL was not distributed with this
3
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5
use std::error::Error;
6
use std::fmt;
7
use std::fmt::Display;
8
9
#[derive(Debug)]
10
pub enum CalendarError {
11
    InvalidYear,
12
    InvalidMonth,
13
    InvalidDay,
14
    InvalidHour,
15
    InvalidMinute,
16
    InvalidSecond,
17
    InvalidDayOfYear,
18
    InvalidWeek,
19
    DivisionByZero,
20
    OutOfBounds,
21
    MixedRadixWrongSize,
22
    MixedRadixZeroBase,
23
    EncounteredNaN,
24
    ImpossibleResult,
25
}
26
27
impl Display for CalendarError {
28
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29
0
        match self {
30
0
            CalendarError::InvalidYear => write!(f, "Invalid Year"),
31
0
            CalendarError::InvalidMonth => write!(f, "Invalid Month"),
32
0
            CalendarError::InvalidDay => write!(f, "Invalid Day"),
33
0
            CalendarError::InvalidHour => write!(f, "Invalid Hour"),
34
0
            CalendarError::InvalidMinute => write!(f, "Invalid Minute"),
35
0
            CalendarError::InvalidSecond => write!(f, "Invalid Second"),
36
0
            CalendarError::InvalidDayOfYear => write!(f, "Invalid day of year"),
37
0
            CalendarError::InvalidWeek => write!(f, "Invalid week"),
38
0
            CalendarError::DivisionByZero => write!(f, "Division By Zero"),
39
0
            CalendarError::OutOfBounds => write!(f, "Out Of Bounds"),
40
0
            CalendarError::MixedRadixWrongSize => write!(f, "Mixed radix slices have wrong size"),
41
0
            CalendarError::MixedRadixZeroBase => write!(f, "Mixed radix base contains zero"),
42
0
            CalendarError::EncounteredNaN => write!(f, "Encountered Not a Number (NaN)"),
43
0
            CalendarError::ImpossibleResult => write!(f, "Impossible result"),
44
        }
45
0
    }
46
}
47
48
impl Error for CalendarError {}