~admicos/moonlander

ref: dde394f1b7b8076ad1de98045f46460e524af11c moonlander/gemini/src/error.rs -rw-r--r-- 1.2 KiB
dde394f1Ecmel Berk Canlier gemini: Make clippy happy a month ago
                                                                                
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
#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error("URL has no scheme, and adding the automatic gemini:// scheme has failed")]
    UrlSchemeError,

    #[error("no hostname found in URL {0}")]
    UrlNoHostError(String),

    #[error("invalid hostname in url")]
    UrlInvalidHostError(#[from] webpki::InvalidDNSNameError),

    #[error("IO error")]
    IoError(#[from] std::io::Error),

    #[error("Untrusted certificate for {host}\n    The server might have changed certificates.\n    Currently trusting ({algorithm}) {expected_fingerprint}")]
    UntrustedCertificate {
        host: String,
        algorithm: String,
        expected_fingerprint: String,
    },

    #[error("couldn't detect a Gemini header in response")]
    ResponseNoHeader,

    #[error("response header invalid, no status code")]
    ResponseInvalidHeader,

    #[error("response header invalid, invalid status code '{0}'")]
    ResponseInvalidHeaderStatus(String),

    #[error("response header invalid, status code '{0}' requires meta")]
    ResponseInvalidHeaderNoMeta(u8),

    #[error("TLS Error")]
    TlsError(#[from] rustls::TLSError),
}

pub type Result<T> = std::result::Result<T, Error>;