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
// SPDX-License-Identifier: MIT
// Copyright 2023 IROX Contributors
//

use crate::address::AddressError;
use irox_tools::{impl_err_fn, impl_error, impl_from_error};

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum ErrorType {
    IOError,
    AddressError,
    MissingPort,
    UnknownScheme,
}

impl_error!(Error, ErrorType);
impl_from_error!(Error, std::io::Error, ErrorType::IOError);
impl_from_error!(Error, AddressError, ErrorType::AddressError);

impl_err_fn!(
    Error,
    ErrorType::MissingPort,
    missing_port,
    missing_port_err
);
impl_err_fn!(
    Error,
    ErrorType::UnknownScheme,
    unknown_scheme,
    unknown_scheme_err
);