orinium_browser/platform/network/
error.rs

1//! Network error types.
2
3#[derive(Debug)]
4pub enum NetworkError {
5    // Request / protocol
6    InvalidUri,
7    MissingHost,
8    InvalidDnsName,
9
10    // Transport
11    ConnectionFailed,
12    TlsFailed,
13    Timeout,
14
15    // HTTP
16    HttpHandshakeFailed,
17    HttpRequestFailed,
18    HttpResponseFailed,
19    TooManyRedirects,
20    UnsupportedHttpVersion,
21
22    // Infrastructure
23    Disconnected,
24}
25
26impl std::fmt::Display for NetworkError {
27    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28        use NetworkError::*;
29        let msg = match self {
30            InvalidUri => "invalid URI",
31            MissingHost => "URI has no host",
32            InvalidDnsName => "invalid DNS name",
33
34            ConnectionFailed => "connection failed",
35            TlsFailed => "TLS handshake failed",
36            Timeout => "network timeout",
37
38            HttpHandshakeFailed => "HTTP handshake failed",
39            HttpRequestFailed => "HTTP request failed",
40            HttpResponseFailed => "HTTP response failed",
41            TooManyRedirects => "too many redirects",
42            UnsupportedHttpVersion => "unsupported HTTP version",
43
44            Disconnected => "network subsystem disconnected",
45        };
46        write!(f, "{msg}")
47    }
48}
49
50impl std::error::Error for NetworkError {}