summaryrefslogtreecommitdiffstats
path: root/src/error.rs
blob: 43413d732dd87d8b25119c9073e1d4dfbe99dc1b (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use timetype::TimeType;

error_chain! {
    types {
        KairosError, KairosErrorKind, ResultExt, Result;
    }

    links {
    }

    foreign_links {
        NomError(::nom::simple_errors::Err);
    }

    errors {

        UnknownError {
            description("Unknown Error")
            display("Unknown Error")
        }

        CannotAdd(a: TimeType, b: TimeType) {
            description("Cannot add")
            display("Cannot add: {:?} + {:?}", a, b)
        }

        CannotSub(a: TimeType, b: TimeType) {
            description("Cannot subtract")
            display("Cannot subtract: {:?} - {:?}", a, b)
        }

        ArgumentErrorNotAnAmount(tt: TimeType) {
            description("Argument Error: Not an amount TimeType object")
            display("The passed argument is not an amount: {:?}", tt)
        }

        ArgumentErrorNotAMoment(name: &'static str) {
            description("Argument Error: Not a moment TimeType object")
            display("The passed argument is not a moment, but a {}", name)
        }

        CannotCalculateEndOfYearOn(tt: TimeType) {
            description("Argument Error: Cannot calculate end-of-year")
            display("Argument Error: Cannot calculate end-of-year on a {:?}", tt)
        }

        CannotCalculateEndOfMonthOn(tt: TimeType) {
            description("Argument Error: Cannot calculate end-of-month")
            display("Argument Error: Cannot calculate end-of-month on a {:?}", tt)
        }

        CannotCompareDayTo(tt_rep: &'static str) {
            description("Cannot compare Day to non-Moment TimeType")
            display("Cannot compare Day to non-Moment TimeType: {:?}", tt_rep)
        }

        CannotCompareMonthTo(tt_rep: &'static str) {
            description("Cannot compare Month to non-Moment TimeType")
            display("Cannot compare Month to non-Moment TimeType: {:?}", tt_rep)
        }

        OutOfBounds(y: i32, mo: u32, d: u32, hr: u32, mi: u32, s: u32) {
            description("Out of bounds error")
            display("Out of bounds: {}-{}-{}T{}:{}:{}", y, mo, d, hr, mi, s)
        }

        NotADateInsideIterator {
            description("Cannot calculate date for iterator")
            display("Cannot calculate date for iterator")
        }

        UnknownParserError {
            description("Unknown parser error")
            display("Unknown parser error")
        }

    }

}