libproxy/
error.rs

1use std::ffi::NulError;
2use std::string::FromUtf8Error;
3
4/// Couldn't resolve the proxy for the given URL.
5#[derive(Debug)]
6pub struct ProxyResolutionError;
7
8#[derive(Debug)]
9pub enum Error {
10    /// Couldn't resolve the proxy for the given URL.
11    ProxyResolutionError(ProxyResolutionError),
12
13    /// The provided URL couldn't be converted to a CString.
14    InvalidUrl(NulError),
15
16    /// One of the returned proxy URLs was not valid UTF-8.
17    NonUtf8Proxy(FromUtf8Error),
18}
19
20impl From<ProxyResolutionError> for Error {
21    fn from(err: ProxyResolutionError) -> Error {
22        Error::ProxyResolutionError(err)
23    }
24}
25
26impl From<NulError> for Error {
27    fn from(err: NulError) -> Error {
28        Error::InvalidUrl(err)
29    }
30}
31
32impl From<FromUtf8Error> for Error {
33    fn from(err: FromUtf8Error) -> Error {
34        Error::NonUtf8Proxy(err)
35    }
36}