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
#[derive(Debug, Clone, Serialize, Deserialize, Fail, PartialEq, Eq, Hash)]
/// Unexpected check result that's considered minor - we don't want notifications from those
pub enum UnexpectedMinor {
    /// HttpCode (url, code)
    #[fail(display = "URL: {} unavailable. Details: {}", _0, _1)]
    OSError(String, String),

    /// Failed internal function
    #[fail(display = "InternalProtocolProblemFailure on: {}. Details: {}", _0, _1)]
    InternalProtocolProblem(String, String),

    /// Curl multi handler minor failure
    #[fail(display = "{}", _0)]
    HandlerFailed(String),
}

#[derive(Debug, Clone, Serialize, Deserialize, Fail, PartialEq, Eq, Hash)]
/// Unexpected check result
pub enum Unexpected {
    /// Failed to pass page expectation
    #[fail(display = "Failed to connect to URL: {}. Details: {}", _0, _1)]
    URLConnectionProblem(String, String),

    /// Failed to pass page expectation
    #[fail(
        display = "Expired SSL certificate for domain: {}, which is valid only for: {} days",
        _0, _1
    )]
    TLSDomainExpired(String, i32),

    /// Failed to get expected Address
    #[fail(
        display = "URL: {} has invalid final address: \"{}\". Expected: \"{}\"",
        _0, _1, _2
    )]
    AddressInvalid(String, String, String),

    /// Curl multi handler failure
    #[fail(display = "{}", _0)]
    HandlerFailed(String),

    /// Http connection failed
    #[fail(
        display = "URL: {} couldn't be reached in time frame of {} seconds",
        _0, _1
    )]
    HttpConnectionFailed(String, u64),

    /// HttpCode (url, code)
    #[fail(display = "URL: {} returned error: {}. Expected code: {}", _0, _1, _2)]
    HttpCodeInvalid(String, u32, u32),

    /// Content - expected content not found where expected
    #[fail(display = "URL: {} lacks expected content: \"{}\"", _0, _1)]
    ContentInvalid(String, String),

    /// Failed content length check
    #[fail(
        display = "URL: {} is unable to pass minimum-content-length expectation! Actual content length: {}. Expected minimum-length: {}",
        _0, _1, _2
    )]
    ContentLengthInvalid(String, usize, usize),

    /// Check file parse error
    #[fail(
        display = "Failed to parse check input data! Error details: \"{}\"",
        _0
    )]
    CheckParseProblem(String),

    /// Not Implemented functionality
    #[fail(display = "Unmatched validation case for: \"{}\". Details: {}", _0, _1)]
    UnmatchedValidationCase(String, String),
}